scheme48read-image.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  1. #include <stdio.h>
  2. #include "prescheme.h"
  3. #include "scheme48vm-prelude.h"
  4. #include "scheme48vm.h"
  5. #include "scheme48heap.h"
  6. static void relocate_image(long, char *, char *);
  7. static void relocate_symbol_tableB(long, long);
  8. static void relocate_binding_tableB(long, long);
  9. long s48_startup_procedure(void);
  10. long s48_initial_symbols(void);
  11. long s48_initial_imported_bindings(void);
  12. long s48_initial_exported_bindings(void);
  13. long s48_resumer_records(void);
  14. void s48_set_image_valuesB(long, long, long, long, long);
  15. void s48_initializing_gc_root(void);
  16. void s48_initialization_completeB(void);
  17. void s48_reverse_byte_orderB(char *, char *);
  18. void s48_relocate_all(long, char *, char *, long, long, long);
  19. long s48_read_image(char*, long);
  20. static long SstatusS;
  21. static char SeofPS;
  22. static long Sstartup_procedureS;
  23. static long SsymbolsS;
  24. static long Simported_bindingsS;
  25. static long Sexported_bindingsS;
  26. static long Sresumer_recordsS;
  27. static char SinitializingPS;
  28. static void relocate_image(long delta_0X, char * start_1X, char * end_2X)
  29. {
  30. char * arg1K0;
  31. long arg0K0;
  32. long d_5X;
  33. long descriptor_4X;
  34. char * ptr_3X;
  35. { arg1K0 = start_1X;
  36. goto L1673;}
  37. L1673: {
  38. ptr_3X = arg1K0;
  39. if ((ptr_3X < end_2X)) {
  40. descriptor_4X = *((long *) ptr_3X);
  41. if ((3 == (3 & descriptor_4X))) {
  42. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_4X))) + delta_0X))));
  43. goto L1678;}
  44. else {
  45. arg0K0 = descriptor_4X;
  46. goto L1678;}}
  47. else {
  48. return;}}
  49. L1678: {
  50. d_5X = arg0K0;
  51. *((long *) ptr_3X) = (long) (d_5X);
  52. if ((2 == (3 & d_5X))) {
  53. if (((31 & (((d_5X)>>2))) < 17)) {
  54. goto L1692;}
  55. else {
  56. arg1K0 = (ptr_3X + (4 + (-4 & (3 + ((long)(((unsigned long)d_5X)>>8))))));
  57. goto L1673;}}
  58. else {
  59. goto L1692;}}
  60. L1692: {
  61. arg1K0 = (ptr_3X + 4);
  62. goto L1673;}
  63. }
  64. static void relocate_symbol_tableB(long table_6X, long delta_7X)
  65. {
  66. long arg0K0;
  67. char * addr_20X;
  68. long val_19X;
  69. long next_18X;
  70. long next_17X;
  71. long link_16X;
  72. long entry_15X;
  73. char * addr_14X;
  74. long value_13X;
  75. long bucket_12X;
  76. long bucket_11X;
  77. long link_10X;
  78. char temp_9X;
  79. long i_8X;
  80. { if ((3 == (3 & table_6X))) {
  81. if ((2 == (31 & ((((*((long *) ((((char *) (-3 + table_6X))) + -4))))>>2))))) {
  82. arg0K0 = 0;
  83. goto L1850;}
  84. else {
  85. return;}}
  86. else {
  87. return;}}
  88. L1850: {
  89. i_8X = arg0K0;
  90. temp_9X = 1024 == i_8X;
  91. if (temp_9X) {
  92. return;}
  93. else {
  94. link_10X = *((long *) ((((char *) (-3 + table_6X))) + (((i_8X)<<2))));
  95. if ((0 == (3 & link_10X))) {
  96. arg0K0 = (3 + (-4 & link_10X));
  97. goto L1796;}
  98. else {
  99. arg0K0 = link_10X;
  100. goto L1796;}}}
  101. L1796: {
  102. bucket_11X = arg0K0;
  103. if ((1 == bucket_11X)) {
  104. goto L1855;}
  105. else {
  106. bucket_12X = bucket_11X + delta_7X;
  107. if ((3 == (3 & bucket_12X))) {
  108. arg0K0 = (-4 & bucket_12X);
  109. goto L1807;}
  110. else {
  111. arg0K0 = bucket_12X;
  112. goto L1807;}}}
  113. L1855: {
  114. arg0K0 = (1 + i_8X);
  115. goto L1850;}
  116. L1807: {
  117. value_13X = arg0K0;
  118. addr_14X = (((char *) (-3 + table_6X))) + (((i_8X)<<2));S48_WRITE_BARRIER(table_6X, addr_14X, value_13X);
  119. *((long *) addr_14X) = (long) (value_13X);
  120. arg0K0 = bucket_12X;
  121. goto L1813;}
  122. L1813: {
  123. entry_15X = arg0K0;
  124. link_16X = *((long *) ((((char *) (-3 + entry_15X))) + 4));
  125. if ((0 == (3 & link_16X))) {
  126. arg0K0 = (3 + (-4 & link_16X));
  127. goto L1817;}
  128. else {
  129. arg0K0 = link_16X;
  130. goto L1817;}}
  131. L1817: {
  132. next_17X = arg0K0;
  133. if ((1 == next_17X)) {
  134. goto L1855;}
  135. else {
  136. next_18X = next_17X + delta_7X;
  137. if ((3 == (3 & next_18X))) {
  138. arg0K0 = (-4 & next_18X);
  139. goto L1828;}
  140. else {
  141. arg0K0 = next_18X;
  142. goto L1828;}}}
  143. L1828: {
  144. val_19X = arg0K0;
  145. addr_20X = (((char *) (-3 + entry_15X))) + 4;S48_WRITE_BARRIER(entry_15X, addr_20X, val_19X);
  146. *((long *) addr_20X) = (long) (val_19X);
  147. arg0K0 = next_18X;
  148. goto L1813;}
  149. }
  150. static void relocate_binding_tableB(long table_21X, long delta_22X)
  151. {
  152. long arg0K0;
  153. char * addr_35X;
  154. long val_34X;
  155. long next_33X;
  156. long next_32X;
  157. long link_31X;
  158. long entry_30X;
  159. char * addr_29X;
  160. long value_28X;
  161. long bucket_27X;
  162. long bucket_26X;
  163. long link_25X;
  164. char temp_24X;
  165. long i_23X;
  166. { if ((3 == (3 & table_21X))) {
  167. if ((2 == (31 & ((((*((long *) ((((char *) (-3 + table_21X))) + -4))))>>2))))) {
  168. arg0K0 = 0;
  169. goto L2050;}
  170. else {
  171. return;}}
  172. else {
  173. return;}}
  174. L2050: {
  175. i_23X = arg0K0;
  176. temp_24X = 1024 == i_23X;
  177. if (temp_24X) {
  178. return;}
  179. else {
  180. link_25X = *((long *) ((((char *) (-3 + table_21X))) + (((i_23X)<<2))));
  181. if ((0 == (3 & link_25X))) {
  182. arg0K0 = (3 + (-4 & link_25X));
  183. goto L1996;}
  184. else {
  185. arg0K0 = link_25X;
  186. goto L1996;}}}
  187. L1996: {
  188. bucket_26X = arg0K0;
  189. if ((1 == bucket_26X)) {
  190. goto L2055;}
  191. else {
  192. bucket_27X = bucket_26X + delta_22X;
  193. if ((3 == (3 & bucket_27X))) {
  194. arg0K0 = (-4 & bucket_27X);
  195. goto L2007;}
  196. else {
  197. arg0K0 = bucket_27X;
  198. goto L2007;}}}
  199. L2055: {
  200. arg0K0 = (1 + i_23X);
  201. goto L2050;}
  202. L2007: {
  203. value_28X = arg0K0;
  204. addr_29X = (((char *) (-3 + table_21X))) + (((i_23X)<<2));S48_WRITE_BARRIER(table_21X, addr_29X, value_28X);
  205. *((long *) addr_29X) = (long) (value_28X);
  206. arg0K0 = bucket_27X;
  207. goto L2013;}
  208. L2013: {
  209. entry_30X = arg0K0;
  210. link_31X = *((long *) ((((char *) (-3 + entry_30X))) + 12));
  211. if ((0 == (3 & link_31X))) {
  212. arg0K0 = (3 + (-4 & link_31X));
  213. goto L2017;}
  214. else {
  215. arg0K0 = link_31X;
  216. goto L2017;}}
  217. L2017: {
  218. next_32X = arg0K0;
  219. if ((1 == next_32X)) {
  220. goto L2055;}
  221. else {
  222. next_33X = next_32X + delta_22X;
  223. if ((3 == (3 & next_33X))) {
  224. arg0K0 = (-4 & next_33X);
  225. goto L2028;}
  226. else {
  227. arg0K0 = next_33X;
  228. goto L2028;}}}
  229. L2028: {
  230. val_34X = arg0K0;
  231. addr_35X = (((char *) (-3 + entry_30X))) + 12;S48_WRITE_BARRIER(entry_30X, addr_35X, val_34X);
  232. *((long *) addr_35X) = (long) (val_34X);
  233. arg0K0 = next_33X;
  234. goto L2013;}
  235. }
  236. long s48_startup_procedure(void)
  237. {
  238. { return (Sstartup_procedureS);}
  239. }
  240. long s48_initial_symbols(void)
  241. {
  242. { return (SsymbolsS);}
  243. }
  244. long s48_initial_imported_bindings(void)
  245. {
  246. { return (Simported_bindingsS);}
  247. }
  248. long s48_initial_exported_bindings(void)
  249. {
  250. { return (Sexported_bindingsS);}
  251. }
  252. long s48_resumer_records(void)
  253. {
  254. { return (Sresumer_recordsS);}
  255. }
  256. void s48_set_image_valuesB(long startup_proc_36X, long symbols_37X, long imports_38X, long exports_39X, long records_40X)
  257. {
  258. { Sstartup_procedureS = startup_proc_36X;
  259. SsymbolsS = symbols_37X;
  260. Simported_bindingsS = imports_38X;
  261. Sexported_bindingsS = exports_39X;
  262. Sresumer_recordsS = records_40X;
  263. return;}
  264. }
  265. void s48_initializing_gc_root(void)
  266. {
  267. long v_45X;
  268. long v_44X;
  269. long v_43X;
  270. long v_42X;
  271. long v_41X;
  272. { if ((SinitializingPS)) {
  273. v_41X = s48_trace_value((Sstartup_procedureS));
  274. Sstartup_procedureS = v_41X;
  275. v_42X = s48_trace_value((SsymbolsS));
  276. SsymbolsS = v_42X;
  277. v_43X = s48_trace_value((Simported_bindingsS));
  278. Simported_bindingsS = v_43X;
  279. v_44X = s48_trace_value((Sexported_bindingsS));
  280. Sexported_bindingsS = v_44X;
  281. v_45X = s48_trace_value((Sresumer_recordsS));
  282. Sresumer_recordsS = v_45X;
  283. return;}
  284. else {
  285. return;}}
  286. }
  287. void s48_initialization_completeB(void)
  288. {
  289. { SinitializingPS = 0;
  290. return;}
  291. }
  292. void s48_reverse_byte_orderB(char * start_46X, char * end_47X)
  293. {
  294. char * arg1K0;
  295. char * next_52X;
  296. long value_51X;
  297. long x_50X;
  298. long x_49X;
  299. char * ptr_48X;
  300. { ps_write_string("Correcting byte order of resumed image.", (stderr));
  301. { long ignoreXX;
  302. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  303. arg1K0 = start_46X;
  304. goto L1574;}
  305. L1574: {
  306. ptr_48X = arg1K0;
  307. if ((ptr_48X < end_47X)) {
  308. x_49X = *((unsigned char *) ptr_48X);
  309. *((unsigned char *) ptr_48X) = (unsigned char) ((*((unsigned char *) (ptr_48X + 3))));
  310. *((unsigned char *) (ptr_48X + 3)) = (unsigned char) (x_49X);
  311. x_50X = *((unsigned char *) (ptr_48X + 1));
  312. *((unsigned char *) (ptr_48X + 1)) = (unsigned char) ((*((unsigned char *) (ptr_48X + 2))));
  313. *((unsigned char *) (ptr_48X + 2)) = (unsigned char) (x_50X);
  314. value_51X = *((long *) ptr_48X);
  315. next_52X = ptr_48X + 4;
  316. if ((2 == (3 & value_51X))) {
  317. if (((31 & (((value_51X)>>2))) < 17)) {
  318. arg1K0 = next_52X;
  319. goto L1574;}
  320. else {
  321. arg1K0 = (next_52X + (-4 & (3 + ((long)(((unsigned long)value_51X)>>8)))));
  322. goto L1574;}}
  323. else {
  324. arg1K0 = next_52X;
  325. goto L1574;}}
  326. else {
  327. return;}}
  328. }
  329. void s48_relocate_all(long delta_53X, char * new_begin_54X, char * new_hp_55X, long symbols_56X, long imported_57X, long exported_58X)
  330. {
  331. {relocate_symbol_tableB(symbols_56X, delta_53X);relocate_binding_tableB(imported_57X, delta_53X);relocate_binding_tableB(exported_58X, delta_53X);
  332. relocate_image(delta_53X, new_begin_54X, new_hp_55X);
  333. return;}
  334. }
  335. long s48_read_image(char *filename_59X, long heap_size_60X)
  336. {
  337. char * arg1K3;
  338. char * arg1K2;
  339. char * arg1K1;
  340. FILE * arg4K0;
  341. char *arg3K1;
  342. char arg2K1;
  343. char arg2K4;
  344. char arg2K0;
  345. long arg0K2;
  346. long arg0K1;
  347. long arg0K0;
  348. long v_164X;
  349. long descriptor_163X;
  350. long v_162X;
  351. long descriptor_161X;
  352. long v_160X;
  353. long descriptor_159X;
  354. long v_158X;
  355. long status_157X;
  356. long status_156X;
  357. long status_155X;
  358. long status_154X;
  359. long descriptor_153X;
  360. long v_152X;
  361. long descriptor_151X;
  362. long status_150X;
  363. long status_149X;
  364. char eofP_148X;
  365. char v_147X;
  366. char *string_146X;
  367. char okayP_145X;
  368. long status_144X;
  369. long status_143X;
  370. long status_142X;
  371. char eofP_141X;
  372. long got_140X;
  373. long need_139X;
  374. char * new_hp_138X;
  375. long delta_137X;
  376. char reverseP_136X;
  377. char * old_hp_135X;
  378. char * old_begin_134X;
  379. char * new_begin_133X;
  380. FILE * port_132X;
  381. long status_131X;
  382. char eofP_130X;
  383. long status_129X;
  384. long status_128X;
  385. long status_127X;
  386. long x_126X;
  387. long x_125X;
  388. char *string_124X;
  389. char okayP_123X;
  390. long status_122X;
  391. long status_121X;
  392. char eofP_120X;
  393. char ch_119X;
  394. long status_118X;
  395. char eofP_117X;
  396. long got_116X;
  397. char * new_begin_115X;
  398. long v_114X;
  399. long status_113X;
  400. char eofP_112X;
  401. long thing_111X;
  402. long v_110X;
  403. long status_109X;
  404. char eofP_108X;
  405. long thing_107X;
  406. long v_106X;
  407. long status_105X;
  408. char eofP_104X;
  409. long thing_103X;
  410. long v_102X;
  411. long status_101X;
  412. char eofP_100X;
  413. long thing_99X;
  414. long v_98X;
  415. long status_97X;
  416. char eofP_96X;
  417. long thing_95X;
  418. char * old_hp_94X;
  419. long cells_93X;
  420. long status_92X;
  421. char eofP_91X;
  422. long thing_90X;
  423. char * old_begin_89X;
  424. long cells_88X;
  425. long status_87X;
  426. char eofP_86X;
  427. char thing_85X;
  428. long status_84X;
  429. char eofP_83X;
  430. long thing_82X;
  431. long old_bytes_per_cell_81X;
  432. long status_80X;
  433. char eofP_79X;
  434. long status_78X;
  435. char eofP_77X;
  436. char ch_76X;
  437. long i_75X;
  438. long status_74X;
  439. char eofP_73X;
  440. long thing_72X;
  441. char same_versionP_71X;
  442. long status_70X;
  443. char eofP_69X;
  444. long status_68X;
  445. char eofP_67X;
  446. char ch_66X;
  447. long status_65X;
  448. char eofP_64X;
  449. char ch_63X;
  450. long status_62X;
  451. FILE * port_61X;
  452. { port_61X = ps_open_input_file(filename_59X, &status_62X);
  453. if ((status_62X == NO_ERRORS)) {
  454. SstatusS = NO_ERRORS;
  455. SeofPS = 0;
  456. if ((SeofPS)) {
  457. goto L2749;}
  458. else {
  459. goto L3488;}}
  460. else {
  461. ps_write_string("Can't open heap image file", (stderr));
  462. { long ignoreXX;
  463. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  464. ps_write_string((ps_error_string(status_62X)), (stderr));
  465. { long ignoreXX;
  466. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  467. return -1;}}
  468. L2749: {
  469. if ((SeofPS)) {
  470. goto L2782;}
  471. else {
  472. goto L3452;}}
  473. L3488: {
  474. PS_READ_CHAR(port_61X, ch_63X, eofP_64X, status_65X)
  475. if (eofP_64X) {
  476. arg2K0 = eofP_64X;
  477. arg0K1 = status_65X;
  478. goto L2727;}
  479. else {
  480. if ((status_65X == NO_ERRORS)) {
  481. if ((12 == ch_63X)) {
  482. arg2K0 = 0;
  483. arg0K1 = status_65X;
  484. goto L2727;}
  485. else {
  486. goto L3488;}}
  487. else {
  488. arg2K0 = eofP_64X;
  489. arg0K1 = status_65X;
  490. goto L2727;}}}
  491. L2782: {
  492. if ((SeofPS)) {
  493. arg2K0 = 0;
  494. goto L2815;}
  495. else {
  496. arg0K0 = 0;
  497. goto L3428;}}
  498. L3452: {
  499. PS_READ_CHAR(port_61X, ch_66X, eofP_67X, status_68X)
  500. if (eofP_67X) {
  501. arg2K0 = eofP_67X;
  502. arg0K1 = status_68X;
  503. goto L2760;}
  504. else {
  505. if ((status_68X == NO_ERRORS)) {
  506. if ((10 == ch_66X)) {
  507. arg2K0 = 0;
  508. arg0K1 = status_68X;
  509. goto L2760;}
  510. else {
  511. goto L3452;}}
  512. else {
  513. arg2K0 = eofP_67X;
  514. arg0K1 = status_68X;
  515. goto L2760;}}}
  516. L2727: {
  517. eofP_69X = arg2K0;
  518. status_70X = arg0K1;
  519. if (eofP_69X) {
  520. SeofPS = 1;
  521. goto L2749;}
  522. else {
  523. if (((SstatusS) == NO_ERRORS)) {
  524. goto L2749;}
  525. else {
  526. SeofPS = 1;
  527. SstatusS = status_70X;
  528. goto L2749;}}}
  529. L2815: {
  530. same_versionP_71X = arg2K0;
  531. if ((SeofPS)) {
  532. arg0K0 = -1;
  533. goto L2850;}
  534. else {
  535. PS_READ_INTEGER(port_61X, thing_72X, eofP_73X, status_74X)
  536. if (eofP_73X) {
  537. SeofPS = 1;
  538. arg0K0 = -1;
  539. goto L2850;}
  540. else {
  541. if (((SstatusS) == NO_ERRORS)) {
  542. arg0K0 = thing_72X;
  543. goto L2850;}
  544. else {
  545. SeofPS = 1;
  546. SstatusS = status_74X;
  547. arg0K0 = -1;
  548. goto L2850;}}}}
  549. L3428: {
  550. i_75X = arg0K0;
  551. PS_READ_CHAR(port_61X, ch_76X, eofP_77X, status_78X)
  552. if (eofP_77X) {
  553. arg2K0 = 0;
  554. arg2K1 = eofP_77X;
  555. arg0K2 = status_78X;
  556. goto L2793;}
  557. else {
  558. if ((status_78X == NO_ERRORS)) {
  559. if ((i_75X == (strlen((char *) "Vanilla 24")))) {
  560. arg2K0 = (10 == ch_76X);
  561. arg2K1 = 0;
  562. arg0K2 = status_78X;
  563. goto L2793;}
  564. else {
  565. if ((ch_76X == (*("Vanilla 24" + i_75X)))) {
  566. arg0K0 = (1 + i_75X);
  567. goto L3428;}
  568. else {
  569. arg2K0 = 0;
  570. arg2K1 = 0;
  571. arg0K2 = status_78X;
  572. goto L2793;}}}
  573. else {
  574. arg2K0 = 0;
  575. arg2K1 = eofP_77X;
  576. arg0K2 = status_78X;
  577. goto L2793;}}}
  578. L2760: {
  579. eofP_79X = arg2K0;
  580. status_80X = arg0K1;
  581. if (eofP_79X) {
  582. SeofPS = 1;
  583. goto L2782;}
  584. else {
  585. if (((SstatusS) == NO_ERRORS)) {
  586. goto L2782;}
  587. else {
  588. SeofPS = 1;
  589. SstatusS = status_80X;
  590. goto L2782;}}}
  591. L2850: {
  592. old_bytes_per_cell_81X = arg0K0;
  593. if ((SeofPS)) {
  594. arg0K0 = -1;
  595. goto L2885;}
  596. else {
  597. PS_READ_INTEGER(port_61X, thing_82X, eofP_83X, status_84X)
  598. if (eofP_83X) {
  599. SeofPS = 1;
  600. arg0K0 = -1;
  601. goto L2885;}
  602. else {
  603. if (((SstatusS) == NO_ERRORS)) {
  604. arg0K0 = thing_82X;
  605. goto L2885;}
  606. else {
  607. SeofPS = 1;
  608. SstatusS = status_84X;
  609. arg0K0 = -1;
  610. goto L2885;}}}}
  611. L2793: {
  612. thing_85X = arg2K0;
  613. eofP_86X = arg2K1;
  614. status_87X = arg0K2;
  615. if (eofP_86X) {
  616. SeofPS = 1;
  617. arg2K0 = 0;
  618. goto L2815;}
  619. else {
  620. if (((SstatusS) == NO_ERRORS)) {
  621. arg2K0 = thing_85X;
  622. goto L2815;}
  623. else {
  624. SeofPS = 1;
  625. SstatusS = status_87X;
  626. arg2K0 = 0;
  627. goto L2815;}}}
  628. L2885: {
  629. cells_88X = arg0K0;
  630. old_begin_89X = ((char *) (((cells_88X)<<2)));
  631. if ((SeofPS)) {
  632. arg0K0 = -1;
  633. goto L2922;}
  634. else {
  635. PS_READ_INTEGER(port_61X, thing_90X, eofP_91X, status_92X)
  636. if (eofP_91X) {
  637. SeofPS = 1;
  638. arg0K0 = -1;
  639. goto L2922;}
  640. else {
  641. if (((SstatusS) == NO_ERRORS)) {
  642. arg0K0 = thing_90X;
  643. goto L2922;}
  644. else {
  645. SeofPS = 1;
  646. SstatusS = status_92X;
  647. arg0K0 = -1;
  648. goto L2922;}}}}
  649. L2922: {
  650. cells_93X = arg0K0;
  651. old_hp_94X = ((char *) (((cells_93X)<<2)));
  652. if ((SeofPS)) {
  653. arg0K0 = -1;
  654. goto L2959;}
  655. else {
  656. PS_READ_INTEGER(port_61X, thing_95X, eofP_96X, status_97X)
  657. if (eofP_96X) {
  658. SeofPS = 1;
  659. arg0K0 = -1;
  660. goto L2959;}
  661. else {
  662. if (((SstatusS) == NO_ERRORS)) {
  663. arg0K0 = thing_95X;
  664. goto L2959;}
  665. else {
  666. SeofPS = 1;
  667. SstatusS = status_97X;
  668. arg0K0 = -1;
  669. goto L2959;}}}}
  670. L2959: {
  671. v_98X = arg0K0;
  672. SsymbolsS = v_98X;
  673. if ((SeofPS)) {
  674. arg0K0 = -1;
  675. goto L2995;}
  676. else {
  677. PS_READ_INTEGER(port_61X, thing_99X, eofP_100X, status_101X)
  678. if (eofP_100X) {
  679. SeofPS = 1;
  680. arg0K0 = -1;
  681. goto L2995;}
  682. else {
  683. if (((SstatusS) == NO_ERRORS)) {
  684. arg0K0 = thing_99X;
  685. goto L2995;}
  686. else {
  687. SeofPS = 1;
  688. SstatusS = status_101X;
  689. arg0K0 = -1;
  690. goto L2995;}}}}
  691. L2995: {
  692. v_102X = arg0K0;
  693. Simported_bindingsS = v_102X;
  694. if ((SeofPS)) {
  695. arg0K0 = -1;
  696. goto L3031;}
  697. else {
  698. PS_READ_INTEGER(port_61X, thing_103X, eofP_104X, status_105X)
  699. if (eofP_104X) {
  700. SeofPS = 1;
  701. arg0K0 = -1;
  702. goto L3031;}
  703. else {
  704. if (((SstatusS) == NO_ERRORS)) {
  705. arg0K0 = thing_103X;
  706. goto L3031;}
  707. else {
  708. SeofPS = 1;
  709. SstatusS = status_105X;
  710. arg0K0 = -1;
  711. goto L3031;}}}}
  712. L3031: {
  713. v_106X = arg0K0;
  714. Sexported_bindingsS = v_106X;
  715. if ((SeofPS)) {
  716. arg0K0 = -1;
  717. goto L3067;}
  718. else {
  719. PS_READ_INTEGER(port_61X, thing_107X, eofP_108X, status_109X)
  720. if (eofP_108X) {
  721. SeofPS = 1;
  722. arg0K0 = -1;
  723. goto L3067;}
  724. else {
  725. if (((SstatusS) == NO_ERRORS)) {
  726. arg0K0 = thing_107X;
  727. goto L3067;}
  728. else {
  729. SeofPS = 1;
  730. SstatusS = status_109X;
  731. arg0K0 = -1;
  732. goto L3067;}}}}
  733. L3067: {
  734. v_110X = arg0K0;
  735. Sresumer_recordsS = v_110X;
  736. if ((SeofPS)) {
  737. arg0K0 = -1;
  738. goto L3103;}
  739. else {
  740. PS_READ_INTEGER(port_61X, thing_111X, eofP_112X, status_113X)
  741. if (eofP_112X) {
  742. SeofPS = 1;
  743. arg0K0 = -1;
  744. goto L3103;}
  745. else {
  746. if (((SstatusS) == NO_ERRORS)) {
  747. arg0K0 = thing_111X;
  748. goto L3103;}
  749. else {
  750. SeofPS = 1;
  751. SstatusS = status_113X;
  752. arg0K0 = -1;
  753. goto L3103;}}}}
  754. L3103: {
  755. v_114X = arg0K0;
  756. Sstartup_procedureS = v_114X;
  757. if ((SeofPS)) {
  758. goto L3139;}
  759. else {
  760. goto L3359;}}
  761. L3139: {
  762. if (((SstatusS) == NO_ERRORS)) {
  763. if ((SeofPS)) {
  764. SstatusS = EDOM;
  765. ps_write_string("Premature EOF when reading image file", (stderr));
  766. { long ignoreXX;
  767. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  768. if (((SstatusS) == NO_ERRORS)) {
  769. goto L3228;}
  770. else {
  771. ps_write_string((ps_error_string((SstatusS))), (stderr));
  772. { long ignoreXX;
  773. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  774. goto L3228;}}
  775. else {
  776. if (same_versionP_71X) {
  777. if ((4 == old_bytes_per_cell_81X)) {
  778. new_begin_115X = s48_initialize_heap(heap_size_60X, ((((3 + (old_hp_94X - old_begin_89X)))>>2)), old_begin_89X);
  779. got_116X = ps_read_block(port_61X, ((char *) new_begin_115X), 4, &eofP_117X, &status_118X);
  780. if ((status_118X == NO_ERRORS)) {
  781. if (eofP_117X) {
  782. arg2K0 = 0;
  783. arg3K1 = "Premature EOF when reading image file";
  784. goto L2561;}
  785. else {
  786. if ((got_116X < 4)) {
  787. arg2K0 = 0;
  788. arg3K1 = "Read returned too few bytes";
  789. goto L2561;}
  790. else {
  791. arg2K0 = 1;
  792. arg3K1 = "";
  793. goto L2561;}}}
  794. else {
  795. SstatusS = status_118X;
  796. arg2K0 = 0;
  797. arg3K1 = "Error reading from image file";
  798. goto L2561;}}
  799. else {
  800. ps_write_string("Incompatible bytes-per-cell in image", (stderr));
  801. { long ignoreXX;
  802. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  803. if (((SstatusS) == NO_ERRORS)) {
  804. goto L3288;}
  805. else {
  806. ps_write_string((ps_error_string((SstatusS))), (stderr));
  807. { long ignoreXX;
  808. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  809. goto L3288;}}}
  810. else {
  811. ps_write_string("Format of image is incompatible with this version of system", (stderr));
  812. { long ignoreXX;
  813. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  814. if (((SstatusS) == NO_ERRORS)) {
  815. goto L3258;}
  816. else {
  817. ps_write_string((ps_error_string((SstatusS))), (stderr));
  818. { long ignoreXX;
  819. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  820. goto L3258;}}}}
  821. else {
  822. ps_write_string("Error reading from image file", (stderr));
  823. { long ignoreXX;
  824. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  825. if (((SstatusS) == NO_ERRORS)) {
  826. goto L3203;}
  827. else {
  828. ps_write_string((ps_error_string((SstatusS))), (stderr));
  829. { long ignoreXX;
  830. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  831. goto L3203;}}}
  832. L3359: {
  833. PS_READ_CHAR(port_61X, ch_119X, eofP_120X, status_121X)
  834. if (eofP_120X) {
  835. arg2K0 = eofP_120X;
  836. arg0K1 = status_121X;
  837. goto L3117;}
  838. else {
  839. if ((status_121X == NO_ERRORS)) {
  840. if ((12 == ch_119X)) {
  841. arg2K0 = 0;
  842. arg0K1 = status_121X;
  843. goto L3117;}
  844. else {
  845. goto L3359;}}
  846. else {
  847. arg2K0 = eofP_120X;
  848. arg0K1 = status_121X;
  849. goto L3117;}}}
  850. L3228: {
  851. status_122X = ps_close(port_61X);
  852. if ((status_122X == NO_ERRORS)) {
  853. return -1;}
  854. else {
  855. ps_write_string("Error closing image file", (stderr));
  856. { long ignoreXX;
  857. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  858. return -1;}}
  859. L2561: {
  860. okayP_123X = arg2K0;
  861. string_124X = arg3K1;
  862. if (okayP_123X) {
  863. if ((1 == (*((long *) new_begin_115X)))) {
  864. arg4K0 = port_61X;
  865. arg1K1 = new_begin_115X;
  866. arg1K2 = old_begin_89X;
  867. arg1K3 = old_hp_94X;
  868. arg2K4 = 0;
  869. goto L2191;}
  870. else {
  871. x_125X = *((unsigned char *) new_begin_115X);
  872. *((unsigned char *) new_begin_115X) = (unsigned char) ((*((unsigned char *) (new_begin_115X + 3))));
  873. *((unsigned char *) (new_begin_115X + 3)) = (unsigned char) (x_125X);
  874. x_126X = *((unsigned char *) (new_begin_115X + 1));
  875. *((unsigned char *) (new_begin_115X + 1)) = (unsigned char) ((*((unsigned char *) (new_begin_115X + 2))));
  876. *((unsigned char *) (new_begin_115X + 2)) = (unsigned char) (x_126X);
  877. if ((1 == (*((long *) new_begin_115X)))) {
  878. arg4K0 = port_61X;
  879. arg1K1 = new_begin_115X;
  880. arg1K2 = old_begin_89X;
  881. arg1K3 = old_hp_94X;
  882. arg2K4 = 1;
  883. goto L2191;}
  884. else {
  885. ps_write_string("Unable to correct byte order", (stderr));
  886. { long ignoreXX;
  887. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  888. if (((SstatusS) == NO_ERRORS)) {
  889. goto L2658;}
  890. else {
  891. ps_write_string((ps_error_string((SstatusS))), (stderr));
  892. { long ignoreXX;
  893. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  894. goto L2658;}}}}
  895. else {
  896. ps_write_string(string_124X, (stderr));
  897. { long ignoreXX;
  898. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  899. if (((SstatusS) == NO_ERRORS)) {
  900. goto L2612;}
  901. else {
  902. ps_write_string((ps_error_string((SstatusS))), (stderr));
  903. { long ignoreXX;
  904. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  905. goto L2612;}}}
  906. L3288: {
  907. status_127X = ps_close(port_61X);
  908. if ((status_127X == NO_ERRORS)) {
  909. return -1;}
  910. else {
  911. ps_write_string("Error closing image file", (stderr));
  912. { long ignoreXX;
  913. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  914. return -1;}}
  915. L3258: {
  916. status_128X = ps_close(port_61X);
  917. if ((status_128X == NO_ERRORS)) {
  918. return -1;}
  919. else {
  920. ps_write_string("Error closing image file", (stderr));
  921. { long ignoreXX;
  922. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  923. return -1;}}
  924. L3203: {
  925. status_129X = ps_close(port_61X);
  926. if ((status_129X == NO_ERRORS)) {
  927. return -1;}
  928. else {
  929. ps_write_string("Error closing image file", (stderr));
  930. { long ignoreXX;
  931. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  932. return -1;}}
  933. L3117: {
  934. eofP_130X = arg2K0;
  935. status_131X = arg0K1;
  936. if (eofP_130X) {
  937. SeofPS = 1;
  938. goto L3139;}
  939. else {
  940. if (((SstatusS) == NO_ERRORS)) {
  941. goto L3139;}
  942. else {
  943. SeofPS = 1;
  944. SstatusS = status_131X;
  945. goto L3139;}}}
  946. L2191: {
  947. port_132X = arg4K0;
  948. new_begin_133X = arg1K1;
  949. old_begin_134X = arg1K2;
  950. old_hp_135X = arg1K3;
  951. reverseP_136X = arg2K4;
  952. delta_137X = new_begin_133X - old_begin_134X;
  953. new_hp_138X = old_hp_135X + delta_137X;
  954. need_139X = old_hp_135X - old_begin_134X;
  955. got_140X = ps_read_block(port_132X, ((char *) new_begin_133X), need_139X, &eofP_141X, &status_142X);
  956. if ((status_142X == NO_ERRORS)) {
  957. if (eofP_141X) {
  958. arg2K0 = 0;
  959. arg3K1 = "Premature EOF when reading image file";
  960. goto L2199;}
  961. else {
  962. if ((got_140X < need_139X)) {
  963. arg2K0 = 0;
  964. arg3K1 = "Read returned too few bytes";
  965. goto L2199;}
  966. else {
  967. arg2K0 = 1;
  968. arg3K1 = "";
  969. goto L2199;}}}
  970. else {
  971. SstatusS = status_142X;
  972. arg2K0 = 0;
  973. arg3K1 = "Error reading from image file";
  974. goto L2199;}}
  975. L2658: {
  976. status_143X = ps_close(port_61X);
  977. if ((status_143X == NO_ERRORS)) {
  978. return -1;}
  979. else {
  980. ps_write_string("Error closing image file", (stderr));
  981. { long ignoreXX;
  982. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  983. return -1;}}
  984. L2612: {
  985. status_144X = ps_close(port_61X);
  986. if ((status_144X == NO_ERRORS)) {
  987. return -1;}
  988. else {
  989. ps_write_string("Error closing image file", (stderr));
  990. { long ignoreXX;
  991. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  992. return -1;}}
  993. L2199: {
  994. okayP_145X = arg2K0;
  995. string_146X = arg3K1;
  996. PS_READ_CHAR(port_132X, v_147X, eofP_148X, status_149X)
  997. if (okayP_145X) {
  998. if ((status_149X == NO_ERRORS)) {
  999. if (eofP_148X) {
  1000. status_150X = ps_close(port_132X);
  1001. if ((status_150X == NO_ERRORS)) {
  1002. descriptor_151X = Sstartup_procedureS;
  1003. if ((3 == (3 & descriptor_151X))) {
  1004. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_151X))) + delta_137X))));
  1005. goto L2231;}
  1006. else {
  1007. arg0K0 = descriptor_151X;
  1008. goto L2231;}}
  1009. else {
  1010. ps_write_string("Error closing image file", (stderr));
  1011. { long ignoreXX;
  1012. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1013. if (((SstatusS) == NO_ERRORS)) {
  1014. goto L2398;}
  1015. else {
  1016. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1017. { long ignoreXX;
  1018. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1019. goto L2398;}}}
  1020. else {
  1021. ps_write_string("Image file has extraneous data after image", (stderr));
  1022. { long ignoreXX;
  1023. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1024. if (((SstatusS) == NO_ERRORS)) {
  1025. goto L2368;}
  1026. else {
  1027. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1028. { long ignoreXX;
  1029. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1030. goto L2368;}}}
  1031. else {
  1032. ps_write_string("Error reading from image file", (stderr));
  1033. { long ignoreXX;
  1034. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1035. if (((SstatusS) == NO_ERRORS)) {
  1036. goto L2338;}
  1037. else {
  1038. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1039. { long ignoreXX;
  1040. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1041. goto L2338;}}}
  1042. else {
  1043. ps_write_string(string_146X, (stderr));
  1044. { long ignoreXX;
  1045. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1046. if (((SstatusS) == NO_ERRORS)) {
  1047. goto L2308;}
  1048. else {
  1049. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1050. { long ignoreXX;
  1051. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1052. goto L2308;}}}
  1053. L2231: {
  1054. v_152X = arg0K0;
  1055. Sstartup_procedureS = v_152X;
  1056. descriptor_153X = SsymbolsS;
  1057. if ((3 == (3 & descriptor_153X))) {
  1058. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_153X))) + delta_137X))));
  1059. goto L2236;}
  1060. else {
  1061. arg0K0 = descriptor_153X;
  1062. goto L2236;}}
  1063. L2398: {
  1064. status_154X = ps_close(port_132X);
  1065. if ((status_154X == NO_ERRORS)) {
  1066. return -1;}
  1067. else {
  1068. ps_write_string("Error closing image file", (stderr));
  1069. { long ignoreXX;
  1070. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1071. return -1;}}
  1072. L2368: {
  1073. status_155X = ps_close(port_132X);
  1074. if ((status_155X == NO_ERRORS)) {
  1075. return -1;}
  1076. else {
  1077. ps_write_string("Error closing image file", (stderr));
  1078. { long ignoreXX;
  1079. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1080. return -1;}}
  1081. L2338: {
  1082. status_156X = ps_close(port_132X);
  1083. if ((status_156X == NO_ERRORS)) {
  1084. return -1;}
  1085. else {
  1086. ps_write_string("Error closing image file", (stderr));
  1087. { long ignoreXX;
  1088. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1089. return -1;}}
  1090. L2308: {
  1091. status_157X = ps_close(port_132X);
  1092. if ((status_157X == NO_ERRORS)) {
  1093. return -1;}
  1094. else {
  1095. ps_write_string("Error closing image file", (stderr));
  1096. { long ignoreXX;
  1097. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1098. return -1;}}
  1099. L2236: {
  1100. v_158X = arg0K0;
  1101. SsymbolsS = v_158X;
  1102. descriptor_159X = Simported_bindingsS;
  1103. if ((3 == (3 & descriptor_159X))) {
  1104. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_159X))) + delta_137X))));
  1105. goto L2241;}
  1106. else {
  1107. arg0K0 = descriptor_159X;
  1108. goto L2241;}}
  1109. L2241: {
  1110. v_160X = arg0K0;
  1111. Simported_bindingsS = v_160X;
  1112. descriptor_161X = Sexported_bindingsS;
  1113. if ((3 == (3 & descriptor_161X))) {
  1114. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_161X))) + delta_137X))));
  1115. goto L2246;}
  1116. else {
  1117. arg0K0 = descriptor_161X;
  1118. goto L2246;}}
  1119. L2246: {
  1120. v_162X = arg0K0;
  1121. Sexported_bindingsS = v_162X;
  1122. descriptor_163X = Sresumer_recordsS;
  1123. if ((3 == (3 & descriptor_163X))) {
  1124. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_163X))) + delta_137X))));
  1125. goto L2251;}
  1126. else {
  1127. arg0K0 = descriptor_163X;
  1128. goto L2251;}}
  1129. L2251: {
  1130. v_164X = arg0K0;
  1131. Sresumer_recordsS = v_164X;
  1132. if (reverseP_136X) {s48_reverse_byte_orderB(new_begin_133X, new_hp_138X);
  1133. goto L2262;}
  1134. else {
  1135. goto L2262;}}
  1136. L2262: {
  1137. if ((0 == delta_137X)) {
  1138. return 0;}
  1139. else {relocate_symbol_tableB((SsymbolsS), delta_137X);relocate_binding_tableB((Simported_bindingsS), delta_137X);relocate_binding_tableB((Sexported_bindingsS), delta_137X);relocate_image(delta_137X, new_begin_133X, new_hp_138X);
  1140. return 0;}}
  1141. }void
  1142. s48_read_image_init(void)
  1143. {
  1144. SstatusS = NO_ERRORS;
  1145. SeofPS = 0;
  1146. SinitializingPS = 1;
  1147. }