externs.h 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  1. /* externs.h Copyright (C) Codemist 1989-99 */
  2. /*
  3. * Main batch of extern declarations. Must have tags.h loaded first.
  4. *
  5. */
  6. /* Signature: 7754c8eb 07-Mar-2000 */
  7. #ifndef header_externs_h
  8. #define header_externs_h 1
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #ifdef USE_MPI
  13. #include "mpi.h"
  14. extern int32 mpi_rank,mpi_size;
  15. #ifdef MEMORY_TRACE
  16. #define my_pop() (memory_reference((int32)stack), (*stack--))
  17. #else
  18. #define my_pop() (*stack--)
  19. #endif
  20. #endif /* USE_MPI */
  21. extern void **pages,
  22. **heap_pages, **vheap_pages,
  23. **bps_pages, **native_pages;
  24. #ifndef NO_COPYING_GC
  25. extern void **new_heap_pages, **new_vheap_pages,
  26. **new_bps_pages, **new_native_pages;
  27. #endif
  28. extern int32 pages_count,
  29. heap_pages_count, vheap_pages_count,
  30. bps_pages_count, native_pages_count;
  31. #ifndef NO_COPYING_GC
  32. extern int32 new_heap_pages_count, new_vheap_pages_count,
  33. new_bps_pages_count, new_native_pages_count;
  34. #endif
  35. extern int native_pages_changed;
  36. extern int32 native_fringe;
  37. extern Lisp_Object *nilsegment, *stacksegment;
  38. extern Lisp_Object *stackbase;
  39. extern int32 stack_segsize; /* measured in units of one CSL page */
  40. extern DLLexport Lisp_Object *C_stack;
  41. #define stack C_stack
  42. #ifdef MEMORY_TRACE
  43. #define push(a) { *++stack = (a); memory_reference((int32)stack); }
  44. /* push2 etc are just like push, but grouped together */
  45. #define push2(a,b) { *++stack = (a); memory_reference((int32)stack); *++stack = (b); memory_reference((int32)stack); }
  46. #define push3(a,b,c) { *++stack = (a); memory_reference((int32)stack); *++stack = (b); memory_reference((int32)stack); *++stack = (c); memory_reference((int32)stack); }
  47. #define push4(a,b,c,d) { *++stack = (a); memory_reference((int32)stack); *++stack = (b); memory_reference((int32)stack); *++stack = (c); memory_reference((int32)stack); \
  48. *++stack = (d); memory_reference((int32)stack); }
  49. #define push5(a,b,c,d,e){ *++stack = (a); memory_reference((int32)stack); *++stack = (b); memory_reference((int32)stack); *++stack = (c); memory_reference((int32)stack); \
  50. *++stack = (d); memory_reference((int32)stack); *++stack = (e); memory_reference((int32)stack); }
  51. #define push6(a,b,c,d,e,f) {push3(a,b,c); push3(d,e,f)}
  52. #define pop(a) { memory_reference((int32)stack); (a) = *stack--; }
  53. #define pop2(a,b) { memory_reference((int32)stack); (a) = *stack--; memory_reference((int32)stack); (b) = *stack--; }
  54. #define pop3(a,b,c) { memory_reference((int32)stack); (a) = *stack--; memory_reference((int32)stack); (b) = *stack--; memory_reference((int32)stack); (c) = *stack--; }
  55. #define pop4(a,b,c,d) { memory_reference((int32)stack); (a) = *stack--; memory_reference((int32)stack); (b) = *stack--; memory_reference((int32)stack); (c) = *stack--; \
  56. memory_reference((int32)stack); (d) = *stack--; }
  57. #define pop5(a,b,c,d,e) { memory_reference((int32)stack); (a) = *stack--; memory_reference((int32)stack); (b) = *stack--; memory_reference((int32)stack); (c) = *stack--; \
  58. memory_reference((int32)stack); (d) = *stack--; memory_reference((int32)stack); (e) = *stack--; }
  59. #define pop6(a,b,c,d,e,f) {pop3(a,b,c); pop3(d,e,f)}
  60. #define popv(n) stack -= (n);
  61. #else /* MEMORY_TRACE */
  62. #define push(a) { *++stack = (a); }
  63. /* push2 etc are just like push, but grouped together */
  64. #ifdef USE_AUTOINDEX
  65. /*
  66. * Having inspected the code generated by one of the C compilers that
  67. * is frequently used with this Lisp it emerges that the multiple
  68. * push operations might sometimes be much better treated with
  69. * the increment parts explicitly consolidated into one. To leave
  70. * scope for fine-tuning to cmpiler and machine architecture the
  71. * USE_AUTOINDEX macro could be pre-defined and I suspect that on
  72. * VAX and ARM computers it may make good sense.
  73. */
  74. #define push2(a,b) { *++stack = (a); *++stack = (b); }
  75. #define push3(a,b,c) { *++stack = (a); *++stack = (b); *++stack = (c); }
  76. #define push4(a,b,c,d) { *++stack = (a); *++stack = (b); *++stack = (c); \
  77. *++stack = (d); }
  78. #define push5(a,b,c,d,e){ *++stack = (a); *++stack = (b); *++stack = (c); \
  79. *++stack = (d); *++stack = (e); }
  80. #define push6(a,b,c,d,e,f) {push3(a,b,c); push3(d,e,f)}
  81. #define pop(a) { (a) = *stack--; }
  82. #define pop2(a,b) { (a) = *stack--; (b) = *stack--; }
  83. #define pop3(a,b,c) { (a) = *stack--; (b) = *stack--; (c) = *stack--; }
  84. #define pop4(a,b,c,d) { (a) = *stack--; (b) = *stack--; (c) = *stack--; \
  85. (d) = *stack--; }
  86. #define pop5(a,b,c,d,e) { (a) = *stack--; (b) = *stack--; (c) = *stack--; \
  87. (d) = *stack--; (e) = *stack--; }
  88. #define pop6(a,b,c,d,e,f) {pop3(a,b,c); pop3(d,e,f)}
  89. #define popv(n) stack -= (n);
  90. #else /* USE_AUTOINDEX */
  91. #define push2(a,b) { stack[1] = (a); stack[2] = (b); stack += 2; }
  92. #define push3(a,b,c) { stack[1] = (a); stack[2] = (b); stack[3] = (c); \
  93. stack += 3; }
  94. #define push4(a,b,c,d) { stack[1] = (a); stack[2] = (b); stack[3] = (c); \
  95. stack[4] = (d); stack += 4; }
  96. #define push5(a,b,c,d,e){ stack[1] = (a); stack[2] = (b); stack[3] = (c); \
  97. stack[4] = (d); stack[5] = (e); stack += 5; }
  98. #define push6(a,b,c,d,e,f) { \
  99. stack[1] = (a); stack[2] = (b); stack[3] = (c); \
  100. stack[4] = (d); stack[5] = (e); stack[6] = (f); \
  101. stack += 6; }
  102. #define pop(a) { (a) = *stack--; }
  103. #define pop2(a,b) { stack -= 2; (a) = stack[2]; (b) = stack[1]; }
  104. #define pop3(a,b,c) { stack -= 3; (a) = stack[3]; (b) = stack[2]; \
  105. (c) = stack[1]; }
  106. #define pop4(a,b,c,d) { stack -= 4; (a) = stack[4]; (b) = stack[3]; \
  107. (c) = stack[2]; (d) = stack[1]; }
  108. #define pop5(a,b,c,d,e) { stack -= 5; (a) = stack[5]; (b) = stack[4]; \
  109. (c) = stack[3]; (d) = stack[2]; (e) = stack[1]; }
  110. #define pop6(a,b,c,d,e, f) { stack -= 6; \
  111. (a) = stack[6]; (b) = stack[5]; (c) = stack[4]; \
  112. (d) = stack[3]; (e) = stack[2]; (f) = stack[1]; }
  113. #define popv(n) stack -= (n);
  114. #endif /* USE_AUTOINDEX */
  115. #endif /* MEMORY_TRACE*/
  116. #define errexit() { nil = C_nil; if (exception_pending()) return nil; }
  117. #define errexitn(n) { nil = C_nil; \
  118. if (exception_pending()) { popv(n); return nil; } }
  119. #define errexitv() { nil = C_nil; if (exception_pending()) return; }
  120. #define errexitvn(n) { nil = C_nil; \
  121. if (exception_pending()) { popv(n); return; } }
  122. #define GC_USER_SOFT 0
  123. #define GC_USER_HARD 1
  124. #define GC_STACK 2
  125. #define GC_CONS 3
  126. #define GC_VEC 4
  127. #define GC_BPS 5
  128. #define GC_PRESERVE 6
  129. #define GC_NATIVE 7
  130. #ifdef CHECK_STACK
  131. #ifdef SOFTWARE_TICKS
  132. extern DLLexport int32 countdown;
  133. #ifdef INITIAL_SOFTWARE_TICKS
  134. extern DLLexport int32 software_ticks;
  135. #endif
  136. extern DLLexport int deal_with_tick(void);
  137. #define stackcheck0(k) \
  138. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  139. if ((--countdown < 0 && deal_with_tick()) || \
  140. stack >= stacklimit) \
  141. { reclaim(nil, "stack", GC_STACK, 0); \
  142. nil = C_nil; \
  143. if (exception_pending()) { popv(k); return nil; } \
  144. }
  145. #define stackcheck1(k, a1) \
  146. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  147. if ((--countdown < 0 && deal_with_tick()) || \
  148. stack >= stacklimit) \
  149. { a1 = reclaim(a1, "stack", GC_STACK, 0); \
  150. nil = C_nil; \
  151. if (exception_pending()) { popv(k); return nil; } \
  152. }
  153. #define stackcheck2(k, a1, a2) \
  154. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  155. if ((--countdown < 0 && deal_with_tick()) || \
  156. stack >= stacklimit) \
  157. { push(a2); \
  158. a1 = reclaim(a1, "stack", GC_STACK, 0); pop(a2); \
  159. nil = C_nil; \
  160. if (exception_pending()) { popv(k); return nil; } \
  161. }
  162. #define stackcheck3(k, a1, a2, a3) \
  163. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  164. if ((--countdown < 0 && deal_with_tick()) || \
  165. stack >= stacklimit) \
  166. { push2(a2, a3); \
  167. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  168. pop2(a3, a2); \
  169. nil = C_nil; \
  170. if (exception_pending()) { popv(k); return nil; } \
  171. }
  172. #define stackcheck4(k, a1, a2, a3, a4) \
  173. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  174. if ((--countdown < 0 && deal_with_tick()) || \
  175. stack >= stacklimit) \
  176. { push3(a2, a3, a4); \
  177. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  178. pop3(a4, a3, a2); \
  179. nil = C_nil; \
  180. if (exception_pending()) { popv(k); return nil; } \
  181. }
  182. #else /* SOFTWARE_TICKS */
  183. #define stackcheck0(k) \
  184. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  185. if (stack >= stacklimit) \
  186. { reclaim(nil, "stack", GC_STACK, 0); \
  187. nil = C_nil; \
  188. if (exception_pending()) { popv(k); return nil; } \
  189. }
  190. #define stackcheck1(k, a1) \
  191. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  192. if (stack >= stacklimit) \
  193. { a1 = reclaim(a1, "stack", GC_STACK, 0); \
  194. nil = C_nil; \
  195. if (exception_pending()) { popv(k); return nil; } \
  196. }
  197. #define stackcheck2(k, a1, a2) \
  198. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  199. if (stack >= stacklimit) \
  200. { push(a2); \
  201. a1 = reclaim(a1, "stack", GC_STACK, 0); pop(a2); \
  202. nil = C_nil; \
  203. if (exception_pending()) { popv(k); return nil; } \
  204. }
  205. #define stackcheck3(k, a1, a2, a3) \
  206. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  207. if (stack >= stacklimit) \
  208. { push2(a2, a3); \
  209. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  210. pop2(a3, a2); \
  211. nil = C_nil; \
  212. if (exception_pending()) { popv(k); return nil; } \
  213. }
  214. #define stackcheck4(k, a1, a2, a3, a4) \
  215. if (check_stack(__FILE__,__LINE__)) return aerror("stack overflow"); \
  216. if (stack >= stacklimit) \
  217. { push3(a2, a3, a4); \
  218. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  219. pop3(a4, a3, a2); \
  220. nil = C_nil; \
  221. if (exception_pending()) { popv(k); return nil; } \
  222. }
  223. #endif /* SOFTWARE_TICKS */
  224. #else /* CHECK_STACK */
  225. #ifdef SOFTWARE_TICKS
  226. extern DLLexport int32 countdown;
  227. #ifdef INITIAL_SOFTWARE_TICKS
  228. extern DLLexport int32 software_ticks;
  229. #endif
  230. extern DLLexport int deal_with_tick(void);
  231. #define stackcheck0(k) \
  232. if ((--countdown < 0 && deal_with_tick()) || \
  233. stack >= stacklimit) \
  234. { reclaim(nil, "stack", GC_STACK, 0); \
  235. nil = C_nil; \
  236. if (exception_pending()) { popv(k); return nil; } \
  237. }
  238. #define stackcheck1(k, a1) \
  239. if ((--countdown < 0 && deal_with_tick()) || \
  240. stack >= stacklimit) \
  241. { a1 = reclaim(a1, "stack", GC_STACK, 0); \
  242. nil = C_nil; \
  243. if (exception_pending()) { popv(k); return nil; } \
  244. }
  245. #define stackcheck2(k, a1, a2) \
  246. if ((--countdown < 0 && deal_with_tick()) || \
  247. stack >= stacklimit) \
  248. { push(a2); \
  249. a1 = reclaim(a1, "stack", GC_STACK, 0); pop(a2); \
  250. nil = C_nil; \
  251. if (exception_pending()) { popv(k); return nil; } \
  252. }
  253. #define stackcheck3(k, a1, a2, a3) \
  254. if ((--countdown < 0 && deal_with_tick()) || \
  255. stack >= stacklimit) \
  256. { push2(a2, a3); \
  257. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  258. pop2(a3, a2); \
  259. nil = C_nil; \
  260. if (exception_pending()) { popv(k); return nil; } \
  261. }
  262. #define stackcheck4(k, a1, a2, a3, a4) \
  263. if ((--countdown < 0 && deal_with_tick()) || \
  264. stack >= stacklimit) \
  265. { push3(a2, a3, a4); \
  266. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  267. pop3(a4, a3, a2); \
  268. nil = C_nil; \
  269. if (exception_pending()) { popv(k); return nil; } \
  270. }
  271. #else /* SOFTWARE_TICKS */
  272. #define stackcheck0(k) \
  273. if (stack >= stacklimit) \
  274. { reclaim(nil, "stack", GC_STACK, 0); \
  275. nil = C_nil; \
  276. if (exception_pending()) { popv(k); return nil; } \
  277. }
  278. #define stackcheck1(k, a1) \
  279. if (stack >= stacklimit) \
  280. { a1 = reclaim(a1, "stack", GC_STACK, 0); \
  281. nil = C_nil; \
  282. if (exception_pending()) { popv(k); return nil; } \
  283. }
  284. #define stackcheck2(k, a1, a2) \
  285. if (stack >= stacklimit) \
  286. { push(a2); \
  287. a1 = reclaim(a1, "stack", GC_STACK, 0); pop(a2); \
  288. nil = C_nil; \
  289. if (exception_pending()) { popv(k); return nil; } \
  290. }
  291. #define stackcheck3(k, a1, a2, a3) \
  292. if (stack >= stacklimit) \
  293. { push2(a2, a3); \
  294. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  295. pop2(a3, a2); \
  296. nil = C_nil; \
  297. if (exception_pending()) { popv(k); return nil; } \
  298. }
  299. #define stackcheck4(k, a1, a2, a3, a4) \
  300. if (stack >= stacklimit) \
  301. { push3(a2, a3, a4); \
  302. a1 = reclaim(a1, "stack", GC_STACK, 0); \
  303. pop3(a4, a3, a2); \
  304. nil = C_nil; \
  305. if (exception_pending()) { popv(k); return nil; } \
  306. }
  307. #endif /* SOFTWARE_TICKS */
  308. #endif /* CHECK_STACK */
  309. /*
  310. * As well as being used to point directly to the major Lisp item NIL,
  311. * this register is used as a base for a table of other critically
  312. * important other Lisp values. Offsets for at least some of these are
  313. * defined here.
  314. * I also need a proper C external variable holding the value of NIL since
  315. * when called from the C library (e.g. in a signal handler) the global
  316. * register variable will not be available!
  317. */
  318. extern DLLexport Lisp_Object C_nil;
  319. /*
  320. * In COMMON mode the symbol-head for NIL uses the first few offsets
  321. * from NIL here, so I start storing system variables at offset 12 so
  322. * that even if at some stage I expand the size of all identifiers from the
  323. * present state I will be safe.
  324. */
  325. #define first_nil_offset 50 /* GC collector marks from here up */
  326. /*
  327. * A vector of 50 words is used by the interpreter when preparing args
  328. * for functions and when handling multiple values.
  329. */
  330. #define work_0_offset 200
  331. /* Garbage collector marks up to but not including last_nil_offset */
  332. #define last_nil_offset 251
  333. /*
  334. * NIL_SEGMENT_SIZE must be over-large by enough to allow for
  335. * space lost while rounding nil up to be a multiple of 8. Also in the
  336. * Common Lisp case I need to give myself a spare word BEFORE the place
  337. * where C_nil points.
  338. */
  339. #define NIL_SEGMENT_SIZE (last_nil_offset*sizeof(Lisp_Object) + 32)
  340. /*
  341. * I give myself a margin of SPARE bytes at the end of a page so that I can
  342. * always CONS that amount (even without a garbage collection check) and not
  343. * corrupt anything. The main use for this is that sometimes I need to
  344. * convert a set of multiple values or of arguments from values on the
  345. * (C-) stack or wherever va_arg() can find them into a list structure, and
  346. * to avoid horrible potential problems with a garbage collection spotting]
  347. * an exception (notably a ^C interrupt), running arbitrary code in an
  348. * exception ghandler and then continuing, I need to cons those things up
  349. * without any possible GC. The function cons_no_gc does that, and
  350. * I should then call cons_gc_test() afterwards to regularise the situation.
  351. * 512 bytes here leaves room for 64 conses, and I support at most 50
  352. * (multiple-) values so I hope this is safe.
  353. */
  354. #define SPARE 512
  355. #ifdef NILSEG_EXTERNS
  356. /*
  357. * One some computers (ones with plenty of registers, and where the
  358. * main addressing mode is register-indexed, and where optimising
  359. * an compiler can keep variables in registers all the time, it will
  360. * be most efficient to put major system variables addressed as offsets
  361. * from NIL, where I expect to keep nil in a register variable pretty
  362. * well always. On other machines (notable the Intel 80286) that policy
  363. * gives pretty disasterous code, and the use of direct simple external
  364. * variables will win. In PRESERVE and RESTORE I will have to copy
  365. * all the separate external variables into a compact block for
  366. * transfer to and from files. Actually on many (most?) machines the
  367. * choice of whether this option should be enabled or not will be pretty
  368. * marginal and should really be sorted out by building once with
  369. * NILSEG_EXTERNS and once without, and comparing the performance of the
  370. * two resulting systems.
  371. */
  372. #define nil_as_base
  373. extern unsigned32 byteflip;
  374. extern Lisp_Object codefringe;
  375. extern Lisp_Object volatile codelimit;
  376. extern Lisp_Object * volatile stacklimit;
  377. extern Lisp_Object fringe;
  378. extern Lisp_Object volatile heaplimit;
  379. extern Lisp_Object volatile vheaplimit;
  380. extern Lisp_Object vfringe;
  381. extern int32 nwork;
  382. extern int32 exit_reason;
  383. extern DLLexport int32 exit_count;
  384. extern unsigned32 gensym_ser, print_precision, miscflags;
  385. extern int32 current_modulus, fastget_size, package_bits;
  386. extern DLLexport Lisp_Object lisp_true, lambda, funarg, unset_var, opt_key, rest_key;
  387. extern DLLexport Lisp_Object quote_symbol, function_symbol, comma_symbol;
  388. extern DLLexport Lisp_Object comma_at_symbol, cons_symbol, eval_symbol;
  389. extern DLLexport Lisp_Object work_symbol, evalhook, applyhook, macroexpand_hook;
  390. extern DLLexport Lisp_Object append_symbol, exit_tag, exit_value, catch_tags;
  391. extern DLLexport Lisp_Object current_package, startfn;
  392. extern DLLexport Lisp_Object gensym_base, string_char_sym, boffo;
  393. extern DLLexport Lisp_Object err_table;
  394. extern DLLexport Lisp_Object progn_symbol;
  395. extern DLLexport Lisp_Object lisp_work_stream, charvec, raise_symbol, lower_symbol;
  396. extern DLLexport Lisp_Object echo_symbol, codevec, litvec, supervisor, B_reg;
  397. extern DLLexport Lisp_Object savedef, comp_symbol, compiler_symbol, faslvec;
  398. extern DLLexport Lisp_Object tracedfn, lisp_terminal_io;
  399. extern DLLexport Lisp_Object lisp_standard_output, lisp_standard_input, lisp_error_output;
  400. extern DLLexport Lisp_Object lisp_trace_output, lisp_debug_io, lisp_query_io;
  401. extern DLLexport Lisp_Object prompt_thing, faslgensyms;
  402. extern DLLexport Lisp_Object prinl_symbol, emsg_star, redef_msg;
  403. extern DLLexport Lisp_Object expr_symbol, fexpr_symbol, macro_symbol;
  404. extern DLLexport Lisp_Object cl_symbols, active_stream, current_module;
  405. extern DLLexport Lisp_Object features_symbol, lisp_package;
  406. extern DLLexport Lisp_Object sys_hash_table, help_index, cfunarg, lex_words;
  407. extern DLLexport Lisp_Object get_counts, fastget_names, input_libraries;
  408. extern DLLexport Lisp_Object output_library, current_file, break_function;
  409. extern DLLexport Lisp_Object standard_output, standard_input, debug_io;
  410. extern DLLexport Lisp_Object error_output, query_io, terminal_io;
  411. extern DLLexport Lisp_Object trace_output, fasl_stream;
  412. #ifdef COMMON
  413. extern DLLexport Lisp_Object keyword_package;
  414. extern DLLexport Lisp_Object all_packages, package_symbol, internal_symbol;
  415. extern DLLexport Lisp_Object external_symbol, inherited_symbol;
  416. extern DLLexport Lisp_Object key_key, allow_other_keys, aux_key;
  417. extern DLLexport Lisp_Object format_symbol;
  418. extern DLLexport Lisp_Object expand_def_symbol, allow_key_key, declare_symbol;
  419. extern DLLexport Lisp_Object special_symbol;
  420. #endif
  421. extern DLLexport Lisp_Object native_code, native_symbol, traceprint_symbol;
  422. extern DLLexport Lisp_Object loadsource_symbol;
  423. extern DLLexport Lisp_Object hankaku_symbol;
  424. extern Lisp_Object workbase[51];
  425. extern DLLexport Lisp_Object user_base_0, user_base_1, user_base_2;
  426. extern DLLexport Lisp_Object user_base_3, user_base_4, user_base_5;
  427. extern DLLexport Lisp_Object user_base_6, user_base_7, user_base_8;
  428. extern DLLexport Lisp_Object user_base_9;
  429. #define work_0 workbase[0]
  430. #define work_1 workbase[1]
  431. #define mv_1 workbase[1]
  432. #define mv_2 workbase[2]
  433. #define mv_3 workbase[3]
  434. #define work_50 workbase[50]
  435. #else /* NILSEG_EXTERNS */
  436. #define nil_as_base Lisp_Object nil = C_nil;
  437. #define byteflip (*(unsigned32 *)&((Lisp_Object *)nil)[12])
  438. #define codefringe ((Lisp_Object *)nil)[13]
  439. #define codelimit ((Lisp_Object volatile *)nil)[14]
  440. /*
  441. * On a machine where sizeof(void *)=8 and alignment matters I need to arrange for
  442. * stacklimit to be properly aligned. Also I MUST do the address calculation
  443. * in a way that does not get muddled by the "sizeof(void *)" issue. I
  444. * reserve nilseg offsets 15, 16 and 17 for this.
  445. */
  446. #ifdef COMMON
  447. #define stacklimit (*(Lisp_Object * volatile *) \
  448. &((Lisp_Object *)nil)[16])
  449. #else
  450. #define stacklimit (*(Lisp_Object * volatile *) \
  451. &((Lisp_Object *)nil)[15])
  452. #endif
  453. #define fringe ((Lisp_Object *)nil)[18]
  454. #define heaplimit ((Lisp_Object volatile *)nil)[19]
  455. #define vheaplimit ((Lisp_Object volatile *)nil)[20]
  456. #define vfringe ((Lisp_Object *)nil)[21]
  457. #define miscflags (*(unsigned32 *)&((Lisp_Object *)nil)[22])
  458. #define nwork (*(int32 *)&((Lisp_Object *)nil)[24])
  459. #define exit_reason (*(int32 *)&((Lisp_Object *)nil)[25])
  460. #define exit_count (*(int32 *)&((Lisp_Object *)nil)[26])
  461. #define gensym_ser (*(unsigned32 *)&((Lisp_Object *)nil)[27])
  462. #define print_precision (*(unsigned32 *)&((Lisp_Object *)nil)[28])
  463. #define current_modulus (*(int32 *)&((Lisp_Object *)nil)[29])
  464. #define fastget_size (*(int32 *)&((Lisp_Object *)nil)[30])
  465. #define package_bits (*(int32 *)&((Lisp_Object *)nil)[31])
  466. /* offsets 32-49 spare at present */
  467. /* Offset 50 used for EQ hash table list */
  468. /* Offset 51 used for EQUAL hash table list */
  469. #define current_package ((Lisp_Object *)nil)[52]
  470. /* current_package is treated specially by the garbage collector */
  471. #define B_reg ((Lisp_Object *)nil)[53]
  472. #define codevec ((Lisp_Object *)nil)[54]
  473. #define litvec ((Lisp_Object *)nil)[55]
  474. #define exit_tag ((Lisp_Object *)nil)[56]
  475. #define exit_value ((Lisp_Object *)nil)[57]
  476. #define catch_tags ((Lisp_Object *)nil)[58]
  477. #define lisp_package ((Lisp_Object *)nil)[59]
  478. #define boffo ((Lisp_Object *)nil)[60]
  479. #define charvec ((Lisp_Object *)nil)[61]
  480. #define sys_hash_table ((Lisp_Object *)nil)[62]
  481. #define help_index ((Lisp_Object *)nil)[63]
  482. #define gensym_base ((Lisp_Object *)nil)[64]
  483. #define err_table ((Lisp_Object *)nil)[65]
  484. #define supervisor ((Lisp_Object *)nil)[66]
  485. #define startfn ((Lisp_Object *)nil)[67]
  486. #define faslvec ((Lisp_Object *)nil)[68]
  487. #define tracedfn ((Lisp_Object *)nil)[69]
  488. #define prompt_thing ((Lisp_Object *)nil)[70]
  489. #define faslgensyms ((Lisp_Object *)nil)[71]
  490. #define cl_symbols ((Lisp_Object *)nil)[72]
  491. #define active_stream ((Lisp_Object *)nil)[73]
  492. #define current_module ((Lisp_Object *)nil)[74]
  493. /*
  494. * 75-89 spare for workspace-style locations
  495. */
  496. #define append_symbol ((Lisp_Object *)nil)[90]
  497. #define applyhook ((Lisp_Object *)nil)[91]
  498. #define cfunarg ((Lisp_Object *)nil)[92]
  499. #define comma_at_symbol ((Lisp_Object *)nil)[93]
  500. #define comma_symbol ((Lisp_Object *)nil)[94]
  501. #define compiler_symbol ((Lisp_Object *)nil)[95]
  502. #define comp_symbol ((Lisp_Object *)nil)[96]
  503. #define cons_symbol ((Lisp_Object *)nil)[97]
  504. #define echo_symbol ((Lisp_Object *)nil)[98]
  505. #define emsg_star ((Lisp_Object *)nil)[99]
  506. #define evalhook ((Lisp_Object *)nil)[100]
  507. #define eval_symbol ((Lisp_Object *)nil)[101]
  508. #define expr_symbol ((Lisp_Object *)nil)[102]
  509. #define features_symbol ((Lisp_Object *)nil)[103]
  510. #define fexpr_symbol ((Lisp_Object *)nil)[104]
  511. #define funarg ((Lisp_Object *)nil)[105]
  512. #define function_symbol ((Lisp_Object *)nil)[106]
  513. #define lambda ((Lisp_Object *)nil)[107]
  514. #define lisp_true ((Lisp_Object *)nil)[108]
  515. #define lower_symbol ((Lisp_Object *)nil)[109]
  516. #define macroexpand_hook ((Lisp_Object *)nil)[110]
  517. #define macro_symbol ((Lisp_Object *)nil)[111]
  518. #define opt_key ((Lisp_Object *)nil)[112]
  519. #define prinl_symbol ((Lisp_Object *)nil)[113]
  520. #define progn_symbol ((Lisp_Object *)nil)[114]
  521. #define quote_symbol ((Lisp_Object *)nil)[115]
  522. #define raise_symbol ((Lisp_Object *)nil)[116]
  523. #define redef_msg ((Lisp_Object *)nil)[117]
  524. #define rest_key ((Lisp_Object *)nil)[118]
  525. #define savedef ((Lisp_Object *)nil)[119]
  526. #define string_char_sym ((Lisp_Object *)nil)[120]
  527. #define unset_var ((Lisp_Object *)nil)[121]
  528. #define work_symbol ((Lisp_Object *)nil)[122]
  529. #define lex_words ((Lisp_Object *)nil)[123]
  530. #define get_counts ((Lisp_Object *)nil)[124]
  531. #define fastget_names ((Lisp_Object *)nil)[125]
  532. #define input_libraries ((Lisp_Object *)nil)[126]
  533. #define output_library ((Lisp_Object *)nil)[127]
  534. #define current_file ((Lisp_Object *)nil)[128]
  535. #define break_function ((Lisp_Object *)nil)[129]
  536. #define lisp_work_stream ((Lisp_Object *)nil)[130]
  537. #define lisp_standard_output ((Lisp_Object *)nil)[131]
  538. #define lisp_standard_input ((Lisp_Object *)nil)[132]
  539. #define lisp_debug_io ((Lisp_Object *)nil)[133]
  540. #define lisp_error_output ((Lisp_Object *)nil)[134]
  541. #define lisp_query_io ((Lisp_Object *)nil)[135]
  542. #define lisp_terminal_io ((Lisp_Object *)nil)[136]
  543. #define lisp_trace_output ((Lisp_Object *)nil)[137]
  544. #define standard_output ((Lisp_Object *)nil)[138]
  545. #define standard_input ((Lisp_Object *)nil)[139]
  546. #define debug_io ((Lisp_Object *)nil)[140]
  547. #define error_output ((Lisp_Object *)nil)[141]
  548. #define query_io ((Lisp_Object *)nil)[142]
  549. #define terminal_io ((Lisp_Object *)nil)[143]
  550. #define trace_output ((Lisp_Object *)nil)[144]
  551. #define fasl_stream ((Lisp_Object *)nil)[145]
  552. #define native_code ((Lisp_Object *)nil)[146]
  553. #define native_symbol ((Lisp_Object *)nil)[147]
  554. #define traceprint_symbol ((Lisp_Object *)nil)[148]
  555. #define loadsource_symbol ((Lisp_Object *)nil)[149]
  556. #define hankaku_symbol ((Lisp_Object *)nil)[150]
  557. #ifdef COMMON
  558. #define keyword_package ((Lisp_Object *)nil)[170]
  559. #define all_packages ((Lisp_Object *)nil)[171]
  560. #define package_symbol ((Lisp_Object *)nil)[172]
  561. #define internal_symbol ((Lisp_Object *)nil)[173]
  562. #define external_symbol ((Lisp_Object *)nil)[174]
  563. #define inherited_symbol ((Lisp_Object *)nil)[175]
  564. #define key_key ((Lisp_Object *)nil)[176]
  565. #define allow_other_keys ((Lisp_Object *)nil)[177]
  566. #define aux_key ((Lisp_Object *)nil)[178]
  567. #define format_symbol ((Lisp_Object *)nil)[179]
  568. #define expand_def_symbol ((Lisp_Object *)nil)[180]
  569. #define allow_key_key ((Lisp_Object *)nil)[181]
  570. #define declare_symbol ((Lisp_Object *)nil)[182]
  571. #define special_symbol ((Lisp_Object *)nil)[183]
  572. #endif
  573. /*
  574. * The next are intended for use by people building custom versions
  575. * of CSL. They are always handled as if NILSEG_EXTERNS had been set,
  576. * even if it had not, since that gives the user direct access to them as
  577. * simple C variables. Note that they must ALWAYS be kept with proper
  578. * valid Lisp objects in them.
  579. */
  580. /* #define user_base_0 ((Lisp_Object *)nil)[190] */
  581. /* #define user_base_1 ((Lisp_Object *)nil)[191] */
  582. /* #define user_base_2 ((Lisp_Object *)nil)[192] */
  583. /* #define user_base_3 ((Lisp_Object *)nil)[193] */
  584. /* #define user_base_4 ((Lisp_Object *)nil)[194] */
  585. /* #define user_base_5 ((Lisp_Object *)nil)[195] */
  586. /* #define user_base_6 ((Lisp_Object *)nil)[196] */
  587. /* #define user_base_7 ((Lisp_Object *)nil)[197] */
  588. /* #define user_base_8 ((Lisp_Object *)nil)[198] */
  589. /* #define user_base_9 ((Lisp_Object *)nil)[199] */
  590. extern DLLexport Lisp_Object user_base_0, user_base_1, user_base_2;
  591. extern DLLexport Lisp_Object user_base_3, user_base_4, user_base_5;
  592. extern DLLexport Lisp_Object user_base_6, user_base_7, user_base_8;
  593. extern DLLexport Lisp_Object user_base_9;
  594. #define work_0 ((Lisp_Object *)nil)[200]
  595. #define work_1 ((Lisp_Object *)nil)[201]
  596. #define mv_1 work_1
  597. #define mv_2 ((Lisp_Object *)nil)[202]
  598. #define mv_3 ((Lisp_Object *)nil)[203]
  599. #define work_50 ((Lisp_Object *)nil)[250]
  600. #endif /*NILSEG_EXTERNS */
  601. /* dummy_function_call is only used to patch around C compiler bugs! */
  602. extern void MS_CDECL dummy_function_call(char *why, ...);
  603. extern void copy_into_nilseg(int fg);
  604. extern void copy_out_of_nilseg(int fg);
  605. #define eq_hash_table_list ((Lisp_Object *)nil)[50] /* In heap image */
  606. #define equal_hash_table_list ((Lisp_Object *)nil)[51] /* In heap image */
  607. #define current_package_offset 52
  608. extern void rehash_this_table(Lisp_Object v);
  609. extern Lisp_Object eq_hash_tables, equal_hash_tables;
  610. /*
  611. * The following are used to help <escape> processing.
  612. */
  613. extern Lisp_Object volatile savecodelimit;
  614. extern Lisp_Object * volatile savestacklimit;
  615. extern Lisp_Object volatile saveheaplimit;
  616. extern Lisp_Object volatile savevheaplimit;
  617. extern char *exit_charvec;
  618. #ifdef DEBUG
  619. extern int trace_all;
  620. #endif
  621. extern int trace_depth;
  622. #define MAX_INPUT_FILES 40 /* limit on command-line length */
  623. #define MAX_SYMBOLS_TO_DEFINE 40
  624. #define MAX_FASL_PATHS 20
  625. extern char *files_to_read[MAX_INPUT_FILES],
  626. *symbols_to_define[MAX_SYMBOLS_TO_DEFINE],
  627. *fasl_paths[MAX_FASL_PATHS];
  628. extern int fasl_output_file, output_directory;
  629. extern FILE *binary_read_file;
  630. #ifndef COMMON
  631. #ifdef CWIN
  632. extern char **loadable_packages;
  633. extern char **switches;
  634. #endif
  635. #endif
  636. #ifdef SOCKETS
  637. extern int sockets_ready;
  638. extern void flush_socket();
  639. #endif
  640. extern CSLbool undefine_this_one[MAX_SYMBOLS_TO_DEFINE];
  641. extern int number_of_input_files,
  642. number_of_symbols_to_define,
  643. number_of_fasl_paths,
  644. init_flags;
  645. extern int native_code_tag;
  646. extern char *standard_directory;
  647. extern CSLbool gc_method;
  648. extern int32 gc_number;
  649. #define INIT_QUIET 1
  650. #define INIT_VERBOSE 2
  651. #define INIT_EXPANDABLE 4
  652. #define Lispify_predicate(p) ((p) ? lisp_true : nil)
  653. /*
  654. * variables used by the IO system.
  655. */
  656. extern int tty_count;
  657. extern FILE *spool_file;
  658. extern char spool_file_name[32];
  659. typedef struct Ihandle
  660. {
  661. FILE *f; /* File within which this sub-file lives */
  662. long int o; /* Offset (as returned by ftell) */
  663. long int n; /* Number of bytes remaining unread here */
  664. unsigned32 chk; /* Checksum */
  665. int status; /* Reading or Writing */
  666. } Ihandle;
  667. /*
  668. * If there is no more than 100 bytes of data then I will deem
  669. * file compression frivolous. The compression code assumes that
  670. * it has at least 2 bytes to work on, so do NOT cut this limit down to zero.
  671. * Indeed more than that the limit must be greater than the length of
  672. * the initial header record (112 bytes).
  673. */
  674. extern int32 compression_worth_while;
  675. #define CODESIZE 0x1000
  676. typedef struct entry_point
  677. {
  678. void *p;
  679. char *s;
  680. } entry_point;
  681. #ifdef CJAVA
  682. #define entry_table_size 132
  683. #else
  684. #define entry_table_size 127
  685. #endif
  686. extern entry_point entries_table[];
  687. extern int doubled_execution;
  688. #ifdef MEMORY_TRACE
  689. extern int32 memory_base, memory_size;
  690. extern unsigned char *memory_map;
  691. extern FILE *memory_file;
  692. extern void memory_comment(int n);
  693. #endif
  694. #define ARG_CUT_OFF 25
  695. extern void push_args(va_list a, int nargs);
  696. extern void push_args_1(va_list a, int nargs);
  697. extern void Iinit(void);
  698. extern void IreInit(void);
  699. extern void Icontext(Ihandle *);
  700. extern void Irestore_context(Ihandle);
  701. extern void Ilist(void);
  702. extern CSLbool Iopen(char *name, int len, CSLbool dirn, char *expanded_name);
  703. extern CSLbool Iopen_from_stdin();
  704. extern CSLbool IopenRoot(char *expanded_name, int hard);
  705. extern CSLbool Iwriterootp(char *expanded);
  706. extern CSLbool Iopen_help(int32 offset);
  707. extern CSLbool Iopen_banner(int code);
  708. extern CSLbool Imodulep(char *name, int len, char *datestamp, int32 *size,
  709. char *expanded_name);
  710. extern CSLbool Icopy(char *name, int len);
  711. extern CSLbool Idelete(char *name, int len);
  712. extern CSLbool IcloseInput(int check_checksum);
  713. extern CSLbool IcloseOutput();
  714. extern CSLbool Ifinished(void);
  715. extern int Igetc(void);
  716. extern int32 Iread(void *buff, int32 size);
  717. extern CSLbool Iputc(int ch);
  718. extern CSLbool Iwrite(void *buff, int32 size);
  719. extern long int Ioutsize(void);
  720. /*
  721. * I will allow myself 192 bytes to store registration information.
  722. * In my initial implementation I will only use a fraction of that
  723. * but it seems safer to design the structure with extra room for potential
  724. * enhancements. I will keep a version code in the data so that I can update
  725. * my methods but still preserve upwards compatibility when I do that.
  726. */
  727. #define REGISTRATION_SIZE 192
  728. #define REGISTRATION_VERSION "r1.0"
  729. extern unsigned char registration_data[REGISTRATION_SIZE];
  730. extern void MD5_Init();
  731. extern void MD5_Update(unsigned char *data, int len);
  732. extern void MD5_Final(unsigned char *md);
  733. extern CSLbool MD5_busy;
  734. extern unsigned char *MD5(unsigned char *data, int n, unsigned char *md);
  735. extern void checksum(Lisp_Object a);
  736. extern unsigned char unpredictable[256];
  737. extern void inject_randomness(int n);
  738. /*
  739. * crypt_init() seeds the encryption engine that I used, and then
  740. * crypt_get_block() gets a chunk of the sequence, which I can XOR with
  741. * text to mess it up.
  742. */
  743. extern void crypt_init(char *key);
  744. #define CRYPT_BLOCK 128
  745. extern void crypt_get_block(unsigned char result[CRYPT_BLOCK]);
  746. /*
  747. * crypt_active is -ve if none is in use, otherwise it is a key identifier
  748. * (to allow for possibly multiple keys). crypt_buffer & crypt_count are
  749. * things filled in by crypt_get_block(). The encryption stuff here is just
  750. * for protection of the software, and the code that does somewhat more
  751. * serious encryption to create the keys used with this stream cipher live
  752. * elsewhere. The crypto technology in CSL is only used on image files, ie
  753. * chunks of compiled code etc, and no provision has been made to use it
  754. * on user data-files. I can store up to CRYPT_KEYS different keys with
  755. * a CSL system and have different modules protected by different ones of
  756. * them.
  757. */
  758. #define CRYPT_KEYS 10
  759. extern char *crypt_keys[CRYPT_KEYS];
  760. extern int crypt_active;
  761. extern unsigned char *crypt_buffer;
  762. extern int crypt_count;
  763. extern void ensure_screen(void);
  764. extern int window_heading;
  765. #ifndef WINDOW_SYSTEM
  766. #ifdef BUFFERED_STDOUT
  767. extern clock_t last_flush;
  768. #endif
  769. #define start_up_window_manager(a) {}
  770. #endif
  771. extern void my_exit(int n);
  772. extern void *my_malloc(size_t n);
  773. extern clock_t base_time;
  774. extern double *clock_stack;
  775. extern void push_clock(void);
  776. extern double pop_clock(void);
  777. extern double consolidated_time[10], gc_time;
  778. extern CSLbool volatile already_in_gc, tick_on_gc_exit;
  779. extern CSLbool volatile interrupt_pending, tick_pending, polltick_pending;
  780. extern int current_fp_rep;
  781. #ifndef __cplusplus
  782. extern jmp_buf *errorset_buffer;
  783. #endif
  784. extern char *errorset_msg;
  785. extern int errorset_code;
  786. extern void unwind_stack(Lisp_Object *, CSLbool findcatch);
  787. extern CSLbool segvtrap;
  788. extern CSLbool batch_flag;
  789. extern int escaped_printing;
  790. #ifdef __WATCOMC__
  791. extern void low_level_signal_handler(int code);
  792. #else
  793. extern void MS_CDECL low_level_signal_handler(int code);
  794. #endif
  795. extern void MS_CDECL sigint_handler(int code);
  796. #ifdef CHECK_STACK
  797. extern int check_stack(char *file, int line);
  798. #endif
  799. #ifdef RECORD_GET
  800. extern void record_get(Lisp_Object tag, CSLbool found);
  801. #endif
  802. /*
  803. * Functions used internally - not to be installed in Lisp function
  804. * cells, but some of these may end up getting called using special
  805. * non-standard conventions when the Lisp compiler has been at work.
  806. */
  807. extern void adjust_all();
  808. extern void set_up_functions(CSLbool restartp);
  809. extern void get_user_files_checksum(unsigned char *);
  810. extern DLLexport Lisp_Object acons(Lisp_Object a, Lisp_Object b, Lisp_Object c);
  811. extern DLLexport Lisp_Object ash(Lisp_Object a, Lisp_Object b);
  812. extern Lisp_Object bytestream_interpret(Lisp_Object code, Lisp_Object lit,
  813. Lisp_Object *entry_stack);
  814. extern CSLbool complex_stringp(Lisp_Object a);
  815. extern void freshline_trace();
  816. extern void freshline_debug();
  817. extern DLLexport Lisp_Object cons(Lisp_Object a, Lisp_Object b);
  818. extern Lisp_Object cons_no_gc(Lisp_Object a, Lisp_Object b);
  819. extern Lisp_Object cons_gc_test(Lisp_Object a);
  820. extern void convert_fp_rep(void *p, int old_rep, int new_rep, int type);
  821. extern DLLexport Lisp_Object Ceval(Lisp_Object u, Lisp_Object env);
  822. extern unsigned32 Crand(void);
  823. extern DLLexport Lisp_Object Cremainder(Lisp_Object a, Lisp_Object b);
  824. extern void Csrand(unsigned32 a, unsigned32 b);
  825. extern void discard(Lisp_Object a);
  826. extern DLLexport CSLbool eql_fn(Lisp_Object a, Lisp_Object b);
  827. extern DLLexport CSLbool cl_equal_fn(Lisp_Object a, Lisp_Object b);
  828. extern DLLexport CSLbool equal_fn(Lisp_Object a, Lisp_Object b);
  829. #ifdef TRACED_EQUAL
  830. extern DLLexport CSLbool traced_equal_fn(Lisp_Object a, Lisp_Object b,
  831. char *, int, int);
  832. #define equal_fn(a, b) traced_equal_fn(a, b, __FILE__, __LINE__, 0)
  833. extern void dump_equals();
  834. #endif
  835. extern DLLexport CSLbool equalp(Lisp_Object a, Lisp_Object b);
  836. extern DLLexport Lisp_Object apply(Lisp_Object fn, int nargs,
  837. Lisp_Object env, Lisp_Object fname);
  838. extern DLLexport Lisp_Object apply_lambda(Lisp_Object def, int nargs,
  839. Lisp_Object env, Lisp_Object name);
  840. extern void deallocate_pages(void);
  841. extern void drop_heap_segments(void);
  842. extern DLLexport Lisp_Object gcd(Lisp_Object a, Lisp_Object b);
  843. extern Lisp_Object get_pname(Lisp_Object a);
  844. #ifdef COMMON
  845. extern DLLexport Lisp_Object get(Lisp_Object a, Lisp_Object b, Lisp_Object c);
  846. #else
  847. extern DLLexport Lisp_Object get(Lisp_Object a, Lisp_Object b);
  848. #endif
  849. extern Lisp_Object getvector(int tag, int32 type, int32 length);
  850. extern Lisp_Object getvector_init(int32 n, Lisp_Object v);
  851. extern Lisp_Object getcodevector(int32 type, int32 size);
  852. extern unsigned32 hash_lisp_string(Lisp_Object s);
  853. extern void lose_C_def(Lisp_Object a);
  854. extern DLLexport CSLbool geq2(Lisp_Object a, Lisp_Object b);
  855. extern DLLexport CSLbool greaterp2(Lisp_Object a, Lisp_Object b);
  856. extern DLLexport CSLbool lesseq2(Lisp_Object a, Lisp_Object b);
  857. extern DLLexport CSLbool lessp2(Lisp_Object a, Lisp_Object b);
  858. extern DLLexport Lisp_Object list2(Lisp_Object a, Lisp_Object b);
  859. extern DLLexport Lisp_Object list2star(Lisp_Object a, Lisp_Object b, Lisp_Object c);
  860. extern DLLexport Lisp_Object list3(Lisp_Object a, Lisp_Object b, Lisp_Object c);
  861. extern DLLexport Lisp_Object lognot(Lisp_Object a);
  862. extern DLLexport Lisp_Object macroexpand(Lisp_Object form, Lisp_Object env);
  863. extern Lisp_Object make_one_word_bignum(int32 n);
  864. extern Lisp_Object make_package(Lisp_Object name);
  865. extern Lisp_Object make_string(char *b);
  866. extern Lisp_Object make_nstring(char *b, int32 n);
  867. extern Lisp_Object make_undefined_symbol(char const *s);
  868. extern Lisp_Object make_symbol(char const *s, int restartp,
  869. one_args *f1, two_args *f2, n_args *fn);
  870. extern DLLexport void MS_CDECL stdout_printf(char *fmt, ...);
  871. extern DLLexport void MS_CDECL term_printf(char *fmt, ...);
  872. extern DLLexport void MS_CDECL err_printf(char *fmt, ...);
  873. extern DLLexport void MS_CDECL debug_printf(char *fmt, ...);
  874. extern DLLexport void MS_CDECL trace_printf(char *fmt, ...);
  875. extern char *my_getenv(char *name);
  876. extern DLLexport Lisp_Object ncons(Lisp_Object a);
  877. extern DLLexport Lisp_Object ndelete(Lisp_Object a, Lisp_Object b);
  878. extern DLLexport Lisp_Object negate(Lisp_Object a);
  879. extern DLLexport Lisp_Object nreverse(Lisp_Object a);
  880. extern FILE *open_file(char *filename, char *original_name,
  881. size_t n, char *dirn, FILE *old_file);
  882. extern DLLexport Lisp_Object plus2(Lisp_Object a, Lisp_Object b);
  883. extern void preserve(char *msg);
  884. extern void preserve_native_code();
  885. extern void relocate_native_function(unsigned char *bps);
  886. extern Lisp_Object prin(Lisp_Object u);
  887. extern char *get_string_data(Lisp_Object a, char *why, int32 *len);
  888. extern DLLexport void prin_to_stdout(Lisp_Object u);
  889. extern DLLexport void prin_to_terminal(Lisp_Object u);
  890. extern DLLexport void prin_to_debug(Lisp_Object u);
  891. extern DLLexport void prin_to_query(Lisp_Object u);
  892. extern DLLexport void prin_to_trace(Lisp_Object u);
  893. extern DLLexport void prin_to_error(Lisp_Object u);
  894. extern DLLexport void loop_print_stdout(Lisp_Object o);
  895. extern DLLexport void loop_print_terminal(Lisp_Object o);
  896. extern DLLexport void loop_print_debug(Lisp_Object o);
  897. extern DLLexport void loop_print_query(Lisp_Object o);
  898. extern DLLexport void loop_print_trace(Lisp_Object o);
  899. extern DLLexport void loop_print_error(Lisp_Object o);
  900. extern void internal_prin(Lisp_Object u, int prefix);
  901. extern DLLexport Lisp_Object princ(Lisp_Object u);
  902. extern DLLexport Lisp_Object print(Lisp_Object u);
  903. extern DLLexport Lisp_Object printc(Lisp_Object u);
  904. extern void print_bignum(Lisp_Object u, CSLbool blankp, int nobreak);
  905. extern void print_bighexoctbin(Lisp_Object u,
  906. int radix, int width, CSLbool blankp, int nobreak);
  907. extern DLLexport Lisp_Object putprop(Lisp_Object a, Lisp_Object b,
  908. Lisp_Object c);
  909. extern DLLexport Lisp_Object quot2(Lisp_Object a, Lisp_Object b);
  910. extern DLLexport Lisp_Object rational(Lisp_Object a);
  911. extern void read_eval_print(int noisy);
  912. extern DLLexport Lisp_Object reclaim(Lisp_Object value_to_return, char *why,
  913. int stg_class, int32 size);
  914. extern CSLbool do_not_kill_native_code;
  915. extern void set_fns(Lisp_Object sym, one_args *f1,
  916. two_args *f2, n_args *fn);
  917. extern void setup(int restartp, double storesize);
  918. extern Lisp_Object simplify_string(Lisp_Object s);
  919. extern CSLbool stringp(Lisp_Object a);
  920. extern DLLexport Lisp_Object times2(Lisp_Object a, Lisp_Object b);
  921. extern int32 thirty_two_bits(Lisp_Object a);
  922. #ifdef DEMO_MODE
  923. extern void give_up();
  924. #endif
  925. #ifdef DEMO_BUILD
  926. extern int32 demo_key1, demo_key2;
  927. #endif
  928. /*
  929. * The next few provide support for multiple values.
  930. */
  931. #ifdef COMMON
  932. #define onevalue(r) (exit_count=1, (r))
  933. #define nvalues(r, n) (exit_count=(n), (r))
  934. #else
  935. #define onevalue(r) (r)
  936. #define nvalues(r, n) (r)
  937. #endif
  938. #ifdef COMMON
  939. #define eval(a, b) Ceval(a, b)
  940. #define voideval(a, b) Ceval(a, b)
  941. #else
  942. /*
  943. * I lift the top test from eval out to be in-line so that I can
  944. * (rather often) avoid the overhead of a procedure call when return from
  945. * it will be almost immediate. The effect is that in CSL mode Ceval is
  946. * only ever called on a list. NB the first arg to eval gets evaluated
  947. * several times here - maybe I will just hope that CSE optimisation picks
  948. * up this sort of repetition...
  949. */
  950. #define eval(a, b) \
  951. (is_cons(a) ? Ceval(a, b) : \
  952. is_symbol(a) ? (qvalue(a) == unset_var ? error(1, err_unset_var, a) : \
  953. onevalue(qvalue(a))) : \
  954. onevalue(a))
  955. /* voideval(a, b) is like (void)eval(a, b) */
  956. #define voideval(a, b) \
  957. if (is_cons(a)) Ceval(a, b) /* Beware "else" after this */
  958. #endif
  959. /*
  960. * The function "equal" seems to be pretty critical (certainly for Standard
  961. * Lisp mode and Reduce). So I write out the top-level part of it in-line
  962. * and only call the (messy) function in cases where it might be worth-while.
  963. * For Common Lisp I will presumably look at eql and cl_equal as well.
  964. * The test here says:
  965. * If a and b are EQ then they are EQUAL,
  966. * else if a and b have different types they are not EQUAL
  967. * else if a has type 1, 2, 3 or 4 (ie fixnum, odds, sfloat, symbol)
  968. * then they are not EQUAL (those types need to be EQ to be EQUAL)
  969. * otherwise call equal_fn(a, b) to decide the issue.
  970. */
  971. #define equal(a, b) \
  972. ((a) == (b) || \
  973. (((((a) ^ (b)) & TAG_BITS) == 0) && \
  974. ((unsigned)(((a) & TAG_BITS) - 1) > 3) && \
  975. equal_fn(a, b)))
  976. #define cl_equal(a, b) \
  977. ((a) == (b) || \
  978. (((((a) ^ (b)) & TAG_BITS) == 0) && \
  979. ((unsigned)(((a) & TAG_BITS) - 1) > 3) && \
  980. cl_equal_fn(a, b)))
  981. #define eql(a, b) \
  982. ((a) == (b) || \
  983. (((((a) ^ (b)) & TAG_BITS) == 0) && \
  984. ((unsigned)(((a) & TAG_BITS) - 1) > 3) && \
  985. eql_fn(a, b)))
  986. /*
  987. * Helpers for the bignum arithmetic code...
  988. */
  989. #ifndef IMULTIPLY
  990. extern unsigned32 Imultiply(unsigned32 *rlow, unsigned32 a,
  991. unsigned32 b, unsigned32 c);
  992. #endif
  993. #ifndef IDIVIDE
  994. extern unsigned32 Idivide(unsigned32 *qp, unsigned32 a,
  995. unsigned32 b, unsigned32 c);
  996. extern unsigned32 Idiv10_9(unsigned32 *qp, unsigned32 a, unsigned32 b);
  997. #endif
  998. /*
  999. * UNSAFE removes some checks - but it does noy seem to make much difference
  1000. * so I rather strongly suggest that you do not enable it!
  1001. */
  1002. #ifdef UNSAFE
  1003. # define argcheck(var, n, msg) (var) = (var);
  1004. #else
  1005. # define argcheck(var, n, msg) if ((var)!=(n)) return aerror(msg);
  1006. #endif
  1007. extern n_args *zero_arg_functions[];
  1008. extern one_args *one_arg_functions[];
  1009. extern two_args *two_arg_functions[];
  1010. extern n_args *three_arg_functions[];
  1011. extern void *useful_functions[];
  1012. extern char *address_of_var(int n);
  1013. typedef struct setup_type
  1014. {
  1015. char *name;
  1016. one_args *one;
  1017. two_args *two;
  1018. n_args *n;
  1019. } setup_type;
  1020. extern setup_type const
  1021. arith06_setup[], arith08_setup[], arith10_setup[], arith12_setup[],
  1022. char_setup[], eval1_setup[], eval2_setup[], eval3_setup[],
  1023. funcs1_setup[], funcs2_setup[], funcs3_setup[], print_setup[],
  1024. read_setup[], mpi_setup[];
  1025. extern setup_type const
  1026. u01_setup[], u02_setup[], u03_setup[], u04_setup[],
  1027. u05_setup[], u06_setup[], u07_setup[], u08_setup[],
  1028. u09_setup[], u10_setup[], u11_setup[], u12_setup[];
  1029. #ifdef NAG
  1030. extern setup_type const nag_setup[], asp_setup[];
  1031. extern setup_type const socket_setup[], xdr_setup[], grep_setup[];
  1032. extern setup_type const gr_setup[], axfns_setup[];
  1033. #endif
  1034. extern char *find_image_directory(int argc, char *argv[]);
  1035. extern char program_name[64];
  1036. extern Lisp_Object declare_fn(Lisp_Object args, Lisp_Object env);
  1037. extern Lisp_Object function_fn(Lisp_Object args, Lisp_Object env);
  1038. extern Lisp_Object let_fn_1(Lisp_Object bvl, Lisp_Object body,
  1039. Lisp_Object env, int compilerp);
  1040. extern Lisp_Object mv_call_fn(Lisp_Object args, Lisp_Object env);
  1041. extern Lisp_Object progn_fn(Lisp_Object args, Lisp_Object env);
  1042. extern Lisp_Object quote_fn(Lisp_Object args, Lisp_Object env);
  1043. extern Lisp_Object tagbody_fn(Lisp_Object args, Lisp_Object env);
  1044. #ifdef __cplusplus
  1045. }
  1046. #endif
  1047. /*
  1048. * Now declare entrypoints to machine-dependent code fragments...
  1049. */
  1050. #include "sys.h"
  1051. #endif /* header_externs_h */
  1052. /* end of externs.h */