File: xlisp.h

package info (click to toggle)
audacity 2.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 80,076 kB
  • sloc: cpp: 192,859; ansic: 158,072; sh: 34,021; python: 24,248; lisp: 7,495; makefile: 3,667; xml: 573; perl: 31; sed: 16
file content (1029 lines) | stat: -rw-r--r-- 24,740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
/* xlisp - a small subset of lisp */
/*	Copyright (c) 1985, by David Michael Betz
        All Rights Reserved
        Permission is granted for unrestricted non-commercial use

HISTORY
28-Apr-03   Mazzoni
                Added declarations for path.c (new file)
30-Mar-88	Dale Amon CMU-CSD
                Set it up for unix. Picked _TURBOC_  because defs
                are reasonable.
*/

/* system specific definitions */

#include <stdlib.h> /* needed for getenv(); note that this was a problem
    for PMAX implementation, but I assume PMAX is obsolete now. 
    - RBD 16apr04 */
#include <stdio.h>
#include <ctype.h>

/* On the Mac, using _setjmp()/_longjmp() can speed up execution
   quite a bit. */
#if defined(__APPLE__)

#define setjmp slow_setjmp
#define longjmp slow_longjmp
#include <setjmp.h>
#undef setjmp
#undef longjmp
#define setjmp _setjmp
#define longjmp _longjmp

#else
#include <setjmp.h>
#endif


/* NNODES	number of nodes to allocate in each request (1000) */
/* EDEPTH	evaluation stack depth (2000) */
/* ADEPTH	argument stack depth (1000) */
/* FORWARD	type of a forward declaration () */
/* LOCAL	type of a local function (static) */
/* AFMT		printf format for addresses ("%x") */
/* FIXTYPE	data type for fixed point numbers (long) */
/* ITYPE	fixed point input conversion routine type (long atol()) */
/* ICNV		fixed point input conversion routine (atol) */
/* IFMT		printf format for fixed point numbers ("%ld") */
/* FLOTYPE	data type for floating point numbers (float) */
/* OFFTYPE	number the size of an address (int) */

/* for the Win32 environment */
#ifdef WIN32
#define NNODES		2000
#define AFMT		"%lx"
#define OFFTYPE		long
#define SAVERESTORE
#define XL_LITTLE_ENDIAN 
#endif

/* for the Turbo C compiler - MS-DOS, large model */
#ifdef _TURBOC_
#define NNODES		2000
#define AFMT		"%lx"
#define OFFTYPE		long
#define SAVERESTORE
#define XL_LITTLE_ENDIAN
#endif

/* for the AZTEC C compiler - MS-DOS, large model */
#ifdef AZTEC_LM
#define NNODES		2000
#define AFMT		"%lx"
#define OFFTYPE		long
#define CVPTR(x)	ptrtoabs(x)
#define NIL		(void *)0
extern long ptrtoabs();
#define SAVERESTORE
#define XL_LITTLE_ENDIAN
#endif

/* for the AZTEC C compiler - Macintosh */
#ifdef AZTEC_MAC
#define NNODES		2000
#define AFMT		"%lx"
#define OFFTYPE		long
#define NIL		(void *)0
#define SAVERESTORE
#define XL_BIG_ENDIAN
#endif

/* for the AZTEC C compiler - Amiga */
#ifdef AZTEC_AMIGA
#define NNODES		2000
#define AFMT		"%lx"
#define OFFTYPE		long
#define NIL		(void *)0
#define SAVERESTORE
#define XL_BIG_ENDIAN
#endif

/* for the Lightspeed C compiler - Macintosh */
#ifdef LSC
#define NNODES		2000
#define AFMT		"%lx"
#define OFFTYPE		long
#define NIL		(void *)0
#define SAVERESTORE
#define XL_BIG_ENDIAN
#endif

/* for the Microsoft C compiler - MS-DOS, large model */
#ifdef MSC
#define NNODES		2000
#define AFMT		"%lx"
#define OFFTYPE		long
#define XL_LITTLE_ENDIAN
#endif

/* for the Mark Williams C compiler - Atari ST */
#ifdef MWC
#define AFMT		"%lx"
#define OFFTYPE		long
#define XL_BIG_ENDIAN
#endif

/* for the Lattice C compiler - Atari ST */
#ifdef LATTICE
#define FIXTYPE		int
#define ITYPE		int atoi()
#define ICNV(n)		atoi(n)
#define IFMT		"%d"
#define XL_BIG_ENDIAN
#endif

/* for the Digital Research C compiler - Atari ST */
#ifdef DR
#define LOCAL
#define AFMT		"%lx"
#define OFFTYPE		long
#undef NULL
#define NULL		0L
#define XL_BIG_ENDIAN
#endif

/* Mac Metrowerks CW 6 */
#ifdef __MWERKS__
#define LSC
#undef PATHNAMES
#undef FILETABLE
#undef SAVERESTORE
#undef MEDMEM
#define EDEPTH 4000
#define ADEPTH 3000
#define OSAOPEN osaopen
#define OSBOPEN osbopen
#define NO_EXTENSIONS  /* don't add ".lsp" onto filenames */
#define XL_BIG_ENDIAN
#endif

/* Linux on Pentium */
#if defined(__linux__) || defined(__GLIBC__)
#include <endian.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define XL_LITTLE_ENDIAN
#else
#define XL_BIG_ENDIAN
#endif
#endif

/* Apple CC */
#ifdef __APPLE__
#define NNODES 2000
#define AFMT "%lx"
#define OFFTYPE long
#define NIL (void *)0
#define SAVERESTORE
#include <sys/types.h>
/* #if __BYTE_ORDER == __LITTLE_ENDIAN */
#if defined(__LITTLE_ENDIAN__)
#define XL_LITTLE_ENDIAN
#else
#define XL_BIG_ENDIAN
#endif
#endif

/* default important definitions */
#ifndef NNODES
#define NNODES		1000
#endif
#ifndef NTYPES
#define NTYPES		20
#endif
#ifndef EDEPTH
/* originally was 2000 */
#define EDEPTH		4000
#endif
#ifndef ADEPTH
/* originally was 1000 */
#define ADEPTH		2000
#endif
#ifndef FORWARD
#define FORWARD
#endif
#ifndef LOCAL
#define LOCAL		static
#endif
#ifndef AFMT
#define AFMT		"%x"
#endif
#ifndef FIXTYPE
#define FIXTYPE		long
#endif
#ifndef ITYPE
#ifndef atol  /* if atol is a macro, this will mess things up */
#define ITYPE		long atol()
#endif
#endif
#ifndef ICNV
#define ICNV(n)		atol(n)
#endif
#ifndef IFMT
#define IFMT		"%ld"
#endif
#ifndef FLOTYPE
#define FLOTYPE		double
#endif
#ifndef OFFTYPE
#define OFFTYPE		int
#endif
#ifndef CVPTR
#define CVPTR(x)	(x)
#endif
#ifndef UCHAR
#define UCHAR		unsigned char
#endif

#ifndef STDERR
#define STDERR stderr
#endif

/* useful definitions */
#ifndef TRUE
#define TRUE	1
#define FALSE	0
#endif
#define externp(x) ((x) && ntype(x) == EXTERN)
#ifndef NIL
#define NIL	(LVAL )0
#endif

/* include the dynamic memory definitions */
#include "xldmem.h"

/* program limits */
#define STRMAX		250		/* maximum length of a string constant */
/* this was 100 -- I had a perfectly good full path to init.lsp using
   a directory structure created by Apple's Xcode that was about 108
   characters, so I picked a bigger value. -RBD */

#define HSIZE		1499		/* symbol hash table size */
#define SAMPLE		1000		/* control character sample rate */

/* function table offsets for the initialization functions */
#define FT_RMHASH	0
#define FT_RMQUOTE	1
#define FT_RMDQUOTE	2
#define FT_RMBQUOTE	3
#define FT_RMCOMMA	4
#define FT_RMLPAR	5
#define FT_RMRPAR	6
#define FT_RMSEMI	7
#define FT_CLNEW	10
#define FT_CLISNEW	11
#define FT_CLANSWER	12
#define FT_OBISNEW	13
#define FT_OBCLASS	14
#define FT_OBSHOW	15
#define FT_OBISA        16
        
/* macro to push a value onto the argument stack */
#define pusharg(x)	{if (xlsp >= xlargstktop) xlargstkoverflow();\
                         *xlsp++ = (x);}

/* #define DEBUG_GC */

/* macros to protect pointers */
#ifdef DEBUG_GC
void dbg_gc_xlsave(LVAL *n);

#define xlstkcheck(n)	{if (xlstack - (n) < xlstkbase) xlstkoverflow();}
#define xlsave(n)	{*--xlstack = &n; n = NIL; dbg_gc_xlsave(&n);}
#define xlprotect(n)	{*--xlstack = &n; dbg_gc_xlsave(&n);}

/* check the stack and protect a single pointer */
#define xlsave1(n)	{if (xlstack <= xlstkbase) xlstkoverflow();\
                         *--xlstack = &n; n = NIL; dbg_gc_xlsave(&n);}
#define xlprot1(n)	{if (xlstack <= xlstkbase) xlstkoverflow();\
                         *--xlstack = &n; dbg_gc_xlsave(&n);}

/* macros to pop pointers off the stack */
#define xlpop()		{++xlstack;}
#define xlpopn(n)	{xlstack+=(n);}

#else

#define xlstkcheck(n)	{if (xlstack - (n) < xlstkbase) xlstkoverflow();}
#define xlsave(n)	{*--xlstack = &n; n = NIL;}
#define xlprotect(n)	{*--xlstack = &n;}

/* check the stack and protect a single pointer */
#define xlsave1(n)	{if (xlstack <= xlstkbase) xlstkoverflow();\
                         *--xlstack = &n; n = NIL;}
#define xlprot1(n)	{if (xlstack <= xlstkbase) xlstkoverflow();\
                         *--xlstack = &n;}

/* macros to pop pointers off the stack */
#define xlpop()		{++xlstack;}
#define xlpopn(n)	{xlstack+=(n);}
#endif

/* macros to manipulate the lexical environment */
#define xlframe(e)	cons(NIL,e)
#define xlbind(s,v)	xlpbind(s,v,xlenv)
#define xlfbind(s,v)	xlpbind(s,v,xlfenv);
#define xlpbind(s,v,e)	{rplaca(e,cons(cons(s,v),car(e)));}

/* macros to manipulate the dynamic environment */
#define xldbind(s,v)	{xldenv = cons(cons(s,getvalue(s)),xldenv);\
                         setvalue(s,v);}
#define xlunbind(e)	{for (; xldenv != (e); xldenv = cdr(xldenv))\
                           setvalue(car(car(xldenv)),cdr(car(xldenv)));}

/* type predicates */			       
#define atomp(x)		((x) == NIL || ntype(x) != CONS)
#define null(x)		((x) == NIL)
#define listp(x)	((x) == NIL || ntype(x) == CONS)
#define consp(x)	((x) && ntype(x) == CONS)
#define subrp(x)	((x) && ntype(x) == SUBR)
#define fsubrp(x)	((x) && ntype(x) == FSUBR)
#define stringp(x)	((x) && ntype(x) == STRING)
#define symbolp(x)	((x) && ntype(x) == SYMBOL)
#define streamp(x)	((x) && ntype(x) == STREAM)
#define objectp(x)	((x) && ntype(x) == OBJECT)
#define fixp(x)		((x) && ntype(x) == FIXNUM)
#define floatp(x)	((x) && ntype(x) == FLONUM)
#define vectorp(x)	((x) && ntype(x) == VECTOR)
#define closurep(x)	((x) && ntype(x) == CLOSURE)
#define charp(x)	((x) && ntype(x) == CHAR)
#define ustreamp(x)	((x) && ntype(x) == USTREAM)
#define boundp(x)	(getvalue(x) != s_unbound)
#define fboundp(x)	(getfunction(x) != s_unbound)

/* shorthand functions */
#define consa(x)	cons(x,NIL)
#define consd(x)	cons(NIL,x)

/* argument list parsing macros */
#define xlgetarg()	(testarg(nextarg()))
#define xllastarg()	{if (xlargc != 0) xltoomany();}
#define testarg(e)	(moreargs() ? (e) : xltoofew())
#define typearg(tp)	(tp(*xlargv) ? nextarg() : xlbadtype(*xlargv))
#define nextarg()	(--xlargc, *xlargv++)
#define moreargs()	(xlargc > 0)

/* macros to get arguments of a particular type */
#define xlgacons()	(testarg(typearg(consp)))
#define xlgalist()	(testarg(typearg(listp)))
#define xlgasymbol()	(testarg(typearg(symbolp)))
#define xlgastring()	(testarg(typearg(stringp)))
#define xlgaobject()	(testarg(typearg(objectp)))
#define xlgafixnum()	(testarg(typearg(fixp)))
#define xlgaflonum()	(testarg(typearg(floatp)))
#define xlgachar()	(testarg(typearg(charp)))
#define xlgavector()	(testarg(typearg(vectorp)))
#define xlgastream()	(testarg(typearg(streamp)))
#define xlgaustream()	(testarg(typearg(ustreamp)))
#define xlgaclosure()	(testarg(typearg(closurep)))

/* function definition structure */
typedef struct {
    char *fd_name;	/* function name */
    int fd_type;	/* function type */
    LVAL (*fd_subr)(void);	/* function entry point */
} FUNDEF;

/* execution context flags */
#define CF_GO		0x0001
#define CF_RETURN	0x0002
#define CF_THROW	0x0004
#define CF_ERROR	0x0008
#define CF_CLEANUP	0x0010
#define CF_CONTINUE	0x0020
#define CF_TOPLEVEL	0x0040
#define CF_BRKLEVEL	0x0080
#define CF_UNWIND	0x0100


/* execution context */
typedef struct context {
    int c_flags;			/* context type flags */
    LVAL c_expr;			/* expression (type dependant) */
    jmp_buf c_jmpbuf;			/* longjmp context */
    struct context *c_xlcontext;	/* old value of xlcontext */
    LVAL **c_xlstack;			/* old value of xlstack */
    LVAL *c_xlargv;			/* old value of xlargv */
    int c_xlargc;			/* old value of xlargc */
    LVAL *c_xlfp;			/* old value of xlfp */
    LVAL *c_xlsp;			/* old value of xlsp */
    LVAL c_xlenv;			/* old value of xlenv */
    LVAL c_xlfenv;			/* old value of xlfenv */
    LVAL c_xldenv;			/* old value of xldenv */
} XLCONTEXT;

/* external variables */
extern LVAL **xlstktop;       	/* top of the evaluation stack */
extern LVAL **xlstkbase;	/* base of the evaluation stack */
extern LVAL **xlstack;		/* evaluation stack pointer */
extern LVAL *xlargstkbase;	/* base of the argument stack */
extern LVAL *xlargstktop;	/* top of the argument stack */
extern LVAL *xlfp;		/* argument frame pointer */
extern LVAL *xlsp;		/* argument stack pointer */
extern LVAL *xlargv;		/* current argument vector */
extern int xlargc;		/* current argument count */

/* more external variables */
extern LVAL xlenv,xlfenv,xldenv,xlvalue,s_true;
extern LVAL lk_optional,lk_rest,lk_key,lk_aux,lk_allow_other_keys;
extern LVAL s_evalhook,s_applyhook,s_tracelist;
extern LVAL s_lambda,s_macro;
extern LVAL s_unbound;
extern int xlsample;
extern char buf[];
extern LVAL obarray,s_gcflag,s_gchook;
extern int xldebug;
extern LVAL s_debugio;
extern LVAL s_tracenable,s_tlimit,s_breakenable;
extern LVAL s_loadingfiles;
extern LVAL k_direction,k_input,k_output;
extern LVAL s_stdin,s_stdout;
extern int xlfsize;
/* external variables */
extern LVAL s_car,s_cdr,s_nth,s_get,s_svalue,s_splist,s_aref;
extern LVAL s_comma,s_comat;
extern char gsprefix[];
extern int gsnumber;


/* additional prototypes */

extern FILE *osaopen (char *name, char *mode);
extern FILE *osbopen (char *name, char *mode);

#ifdef __MWERKS__
/* macfun.c */

LVAL xptsize(void);
LVAL xhidepen(void);
LVAL xshowpen(void);
LVAL xgetpen(void);
LVAL xpenmode(void);
LVAL xpensize(void);
LVAL xpenpat(void);
LVAL xpennormal(void);
LVAL xmoveto(void);
LVAL xmove(void);
LVAL xdrawto(void);
LVAL xdraw(void);
LVAL xshowgraphics(void);
LVAL xhidegraphics(void);
LVAL xcleargraphics(void);
LVAL xtool(void);
LVAL xtool16(void);
LVAL xtool32(void);
LVAL xnewhandle(void);
LVAL xnewptr(void);
LVAL xhiword(void);
LVAL xloword(void);
LVAL xrdnohang(void);
/* #include "macstuff.h" */
#endif

/* for extern.c */

void inval_caches();


/* for xlbfun.c */

LVAL xeval(void);
LVAL xapply(void);
LVAL xfuncall(void);
LVAL xmacroexpand(void);
LVAL x1macroexpand(void);
LVAL xatom(void);
LVAL xsymbolp(void);
LVAL xnumberp(void);
LVAL xintegerp(void);
LVAL xfloatp(void);
LVAL xcharp(void);
LVAL xstringp(void);
LVAL xarrayp(void);
LVAL xstreamp(void);
LVAL xobjectp(void);
LVAL xboundp(void);
LVAL xfboundp(void);
LVAL xnull(void);
LVAL xlistp(void);
LVAL xendp(void);
LVAL xconsp(void);
LVAL xeq(void);
LVAL xeql(void);
LVAL xequal(void);
LVAL xset(void);
LVAL xgensym(void);
LVAL xmakesymbol(void);
LVAL xintern(void);
LVAL xsymname(void);
LVAL xsymvalue(void);
LVAL xsymfunction(void);
LVAL xsymplist(void);
LVAL xget(void);
LVAL xputprop(void);
LVAL xremprop(void);
LVAL xhash(void);
LVAL xaref(void);
LVAL xmkarray(void);
LVAL xvector(void);
LVAL xerror(void);
LVAL xcerror(void);
LVAL xbreak(void);
LVAL xcleanup(void);
LVAL xtoplevel(void);
LVAL xcontinue(void);
LVAL xevalhook(void);


/* xlcont.c */

LVAL xquote(void);
LVAL xfunction(void);
LVAL xbquote(void);
LVAL xlambda(void);
LVAL xgetlambda(void);
LVAL xsetq(void);
LVAL xpsetq(void);
LVAL xsetf(void);
LVAL xdefun(void);
LVAL xdefmacro(void);
LVAL xcond(void);
LVAL xwhen(void);
LVAL xunless(void);
LVAL xcase(void);
LVAL xand(void);
LVAL x_or(void); // xor causes problems for gcc, so I renamed it. -RBD
LVAL xif(void);
LVAL xlet(void);
LVAL xletstar(void);
LVAL xflet(void);
LVAL xlabels(void);
LVAL xmacrolet(void);
LVAL xprog(void);
LVAL xprogstar(void);
LVAL xgo(void);
LVAL xreturn(void);
LVAL xrtnfrom(void);
LVAL xprog1(void);
LVAL xprog2(void);
LVAL xprogn(void);
LVAL xprogv(void);
LVAL xloop(void);
LVAL xdo(void);
LVAL xdostar(void);
LVAL xdolist(void);
LVAL xdotimes(void);
LVAL xblock(void);
LVAL xtagbody(void);
LVAL xcatch(void);
LVAL xthrow(void);
LVAL xunwindprotect(void);
LVAL xerrset(void);
LVAL xtrace(void);
LVAL xuntrace(void);


/* xldbug.c */

void xlabort(char *emsg);
void xlbreak(char *emsg, LVAL arg);
void xlfail(char *emsg);
void xlerror(char *emsg, LVAL arg);
void xlcerror(char *cmsg, char *emsg, LVAL arg);
void xlerrprint(char *hdr, char *cmsg, char *emsg, LVAL arg);
void xlbaktrace(int n);
void xldinit(void);
void close_loadingfiles(void);

/* xldmem.c */

LVAL cons(LVAL x, LVAL y);
LVAL cvstring(const char *str);
LVAL new_string(int size);
LVAL cvsymbol(char *pname);
LVAL cvsubr(LVAL (*fcn)(void), int type, int offset);
LVAL cvfile(FILE *fp);
LVAL cvfixnum(FIXTYPE n);
LVAL cvflonum(FLOTYPE n);
LVAL cvchar(int n);
LVAL newustream(void);
LVAL newobject(LVAL cls, int size);
LVAL newclosure(LVAL name, LVAL type, LVAL env, LVAL fenv);
LVAL newvector(int size);
void gc(void);
SEGMENT *newsegment(int n);
LVAL xgc(void);
LVAL xexpand(void);
LVAL xalloc(void);
LVAL xmem(void);
LVAL xsave(void);
LVAL xrestore(void);
void xlminit(void);
LVAL cvextern(xtype_desc typeptr, unsigned char *instptr);		/* convert an external type */
LVAL newnode(int type);
void mark(LVAL ptr);


/* xleval.c */

LVAL xleval(LVAL expr);
LVAL xlxeval(LVAL expr);
LVAL xlapply(int argc);
LVAL xlexpandmacros(LVAL form);
int macroexpand(LVAL fun, LVAL args, LVAL *pval);
int pushargs(LVAL fun, LVAL args);
LVAL makearglist(int argc, LVAL *argv);
LVAL xlclose(LVAL name, LVAL type, LVAL fargs, LVAL body, LVAL env, LVAL fenv);
void xlabind(LVAL fun, int argc, LVAL *argv);
void xlunbound(LVAL sym);
void xlfunbound(LVAL sym);
void xlstkoverflow(void);
void xlargstkoverflow(void);


/* xlfio.c */

LVAL xread(void);
LVAL xprint(void);
LVAL xprin1(void);
LVAL xprinc(void);
LVAL xterpri(void);
LVAL xflatsize(void);
LVAL xflatc(void);
LVAL xopen(void);
LVAL xbopen(void);
LVAL xclose(void);
LVAL xrdchar(void);
LVAL xrdbyte(void);
LVAL xpkchar(void);
LVAL xwrchar(void);
LVAL xwrbyte(void);
LVAL xrdint(void);
LVAL xwrint(void);
LVAL xrdfloat(void);
LVAL xwrfloat(void);
LVAL xreadline(void);
LVAL xmkstrinput(void);
LVAL xmkstroutput(void);
LVAL xgetstroutput(void);
LVAL xgetlstoutput(void);
LVAL xformat(void);
LVAL xlistdir(void);


/* xlimage.c */

int xlisave(char *fname);
int xlirestore(char *fname);


/* xlinit.c */

void xlinit(void);
void xlsymbols(void);


/* xlio.c */

int xlgetc(LVAL fptr);
void xlungetc(LVAL fptr, int ch);
int xlpeek(LVAL fptr);
void xlputc(LVAL fptr, int ch);
void xloutflush(LVAL fptr);
void xlflush(void);
void stdprint(LVAL expr);
void stdputstr(char *str);
void stdflush();
void errprint(LVAL expr);
void errputstr(char *str);
void dbgprint(LVAL expr);
void dbgputstr(char *str);
void trcprin1(LVAL expr);
void trcputstr(char *str);


/* xlisp.c */
long xlrand(long range);
double xlrealrand(void);
void xlrdsave(LVAL expr);
void xlevsave(LVAL expr);
void xlfatal(char *msg);
void xlisp_main_init(int, char **);
void xlisp_main(void);
void xlisp_wrapup(void);


/* xljump.c */

void xlbegin(XLCONTEXT *cptr, int flags, LVAL expr);
void xlend(XLCONTEXT *cptr);
void xlgo(LVAL label);
void xlreturn(LVAL name, LVAL val);
void xlthrow(LVAL tag, LVAL val);
void xlsignal(char *emsg, LVAL arg);
void xltoplevel(void);
void xlbrklevel(void);
void xlcleanup(void);
void xlcontinue(void);
void xljump(XLCONTEXT *target, int mask, LVAL val);


/* xllist.c */

LVAL xcar(void);
LVAL xcdr(void);
LVAL xcaar(void);
LVAL xcadr(void);
LVAL xcdar(void);
LVAL xcddr(void);
LVAL xcaaar(void);
LVAL xcaadr(void);
LVAL xcadar(void);
LVAL xcaddr(void);
LVAL xcdaar(void);
LVAL xcdadr(void);
LVAL xcddar(void);
LVAL xcdddr(void);

/* cxxxxr functions */
LVAL xcaaaar(void);
LVAL xcaaadr(void);
LVAL xcaadar(void);
LVAL xcaaddr(void);
LVAL xcadaar(void);
LVAL xcadadr(void);
LVAL xcaddar(void);
LVAL xcadddr(void);
LVAL xcdaaar(void);
LVAL xcdaadr(void);
LVAL xcdadar(void);
LVAL xcdaddr(void);
LVAL xcddaar(void);
LVAL xcddadr(void);
LVAL xcdddar(void);
LVAL xcddddr(void);
LVAL xcons(void);
LVAL xlist(void);
LVAL xappend(void);
LVAL xreverse(void);
LVAL xlast(void);
LVAL xmember(void);
LVAL xassoc(void);
LVAL xsubst(void);
LVAL xsublis(void);
LVAL xremove(void);
LVAL xremif(void);
LVAL xremifnot(void);
int dotest1(LVAL arg, LVAL fun);
int dotest2(LVAL arg1, LVAL arg2, LVAL fun);
LVAL xnth(void);
LVAL xnthcdr(void);
LVAL xlength(void);
LVAL xmapc(void);
LVAL xmapcar(void);
LVAL xmapl(void);
LVAL xmaplist(void);
LVAL xrplca(void);
LVAL xrplcd(void);
LVAL xnconc(void);
LVAL xdelete(void);
LVAL xdelif(void);
LVAL xdelifnot(void);
LVAL xsort(void);


/* xlmath.c */

LVAL xadd(void);
LVAL xsub(void);
LVAL xmul(void);
LVAL xdiv(void);
LVAL xrem(void);
LVAL xmin(void);
LVAL xmax(void);
LVAL xexpt(void);
LVAL xlogand(void);
LVAL xlogior(void);
LVAL xlogxor(void);
LVAL xgcd(void);
void checkizero(FIXTYPE iarg);
void checkfzero(FLOTYPE farg);
void checkfneg(FLOTYPE farg);
LVAL xlognot(void);
LVAL xabs(void);
LVAL xadd1(void);
LVAL xsub1(void);
LVAL xsin(void);
LVAL xcos(void);
LVAL xtan(void);
LVAL xexp(void);
LVAL xsqrt(void);
LVAL xfix(void);
LVAL xfloat(void);
LVAL xrand(void);
LVAL xminusp(void);
LVAL xzerop(void);
LVAL xplusp(void);
LVAL xevenp(void);
LVAL xoddp(void);
LVAL xlss(void);
LVAL xleq(void);
LVAL xequ(void);
LVAL xneq(void);
LVAL xgeq(void);
LVAL xgtr(void);


/* xlobj.c */

LVAL xsend(void);
LVAL xsendsuper(void);
LVAL xlclass(char *name, int vcnt);
void xladdivar(LVAL cls, char *var);
void xladdmsg(LVAL cls, char *msg, int offset);
int xlobgetvalue(LVAL pair, LVAL sym, LVAL *pval);
int xlobsetvalue(LVAL pair, LVAL sym, LVAL val);
LVAL obisnew(void);
LVAL obclass(void);
LVAL obshow(void);
LVAL obisa(void);
LVAL clnew(void);
LVAL clisnew(void);
LVAL clanswer(void);
void obsymbols(void);
void xloinit(void);


/* xlpp.c */

LVAL xpp(void);


/* xlprin.c */

void xlprint(LVAL fptr, LVAL vptr, int flag);
void xlterpri(LVAL fptr);
void xlputstr(LVAL fptr, char *str);
void putatm(LVAL fptr, char *tag, LVAL val);


/* xlread.c */

int xlload(char *fname, int vflag, int pflag);
int xlread(LVAL fptr, LVAL *pval, int rflag);
int readone(LVAL fptr, LVAL *pval);
LVAL rmhash(void);
LVAL rmquote(void);
LVAL rmdquote(void);
LVAL rmbquote(void);
LVAL rmcomma(void);
LVAL rmlpar(void);
LVAL rmrpar(void);
LVAL rmsemi(void);
LVAL tentry(int ch);
int xlisnumber(char *str, LVAL *pval);
void defmacro(int ch, LVAL type, int offset);
LVAL callmacro(LVAL fptr, int ch);
void xlrinit(void);


/* xlstr.c */

LVAL xstrlss(void);
LVAL xstrleq(void);
LVAL xstreql(void);
LVAL xstrneq(void);
LVAL xstrgeq(void);
LVAL xstrgtr(void);
LVAL xstrilss(void);
LVAL xstrileq(void);
LVAL xstrieql(void);
LVAL xstrineq(void);
LVAL xstrigeq(void);
LVAL xstrigtr(void);
LVAL xupcase(void);
LVAL xdowncase(void);
LVAL xnupcase(void);
LVAL xndowncase(void);
LVAL xstrsearch(void);
LVAL xtrim(void);
LVAL xlefttrim(void);
LVAL xrighttrim(void);
LVAL xstrcat(void);
LVAL xsubseq(void);
LVAL xstring(void);
LVAL xchar(void);
LVAL xcharint(void);
LVAL xintchar(void);
LVAL xuppercasep(void);
LVAL xlowercasep(void);
LVAL xbothcasep(void);
LVAL xdigitp(void);
LVAL xcharcode(void);
LVAL xcodechar(void);
LVAL xchupcase(void);
LVAL xchdowncase(void);
LVAL xdigitchar(void);
LVAL xalphanumericp(void);
LVAL xchrlss(void);
LVAL xchrleq(void);
LVAL xchreql(void);
LVAL xchrneq(void);
LVAL xchrgeq(void);
LVAL xchrgtr(void);
LVAL xchrilss(void);
LVAL xchrileq(void);
LVAL xchrieql(void);
LVAL xchrineq(void);
LVAL xchrigeq(void);
LVAL xchrigtr(void);
LVAL xinfo(void);

/* xlsubr.c */

LVAL xlsubr(char *sname, int type, LVAL (*fcn)(void), int offset);
int xlgetkeyarg(LVAL key, LVAL *pval);
void xltest(LVAL *pfcn, int *ptresult);
int xlgkfixnum(LVAL key, LVAL *pval);
/* argument list parsing functions */
extern LVAL xlgetfile(void);  	/* get a file/stream argument */
extern LVAL xlgetfname(void);	/* get a filename argument */
int needsextension(char *name);
/* error reporting functions (don't *really* return at all) */
extern LVAL xlbadtype(LVAL arg);	/* report "bad argument type" error */
extern LVAL xltoofew(void);		/* report "too few arguments" error */
extern LVAL xltoomany(void);
int eq(LVAL arg1, LVAL arg2);
int eql(LVAL arg1, LVAL arg2);
int lval_equal(LVAL arg1, LVAL arg2);


/* xlsym.c */

LVAL xlenter(char *name);	/* enter a symbol */
LVAL xlmakesym(char *name);	/* make an uninterned symbol */
LVAL xlgetvalue(LVAL sym);	/* get value of a symbol (checked) */
LVAL xlxgetvalue(LVAL sym);	/* get value of a symbol */
void xlsetvalue(LVAL sym, LVAL val);
LVAL xlgetfunction(LVAL sym);	/* get functional value of a symbol */
LVAL xlxgetfunction(LVAL sym);	/* get functional value of a symbol (checked) */
void xlsetfunction(LVAL sym, LVAL val);
LVAL xlgetprop(LVAL sym, LVAL prp);
void xlputprop(LVAL sym, LVAL val, LVAL prp);
void xlremprop(LVAL sym, LVAL prp);
int hash(char *str, int len);
void xlsinit(void);
LVAL findprop(LVAL sym, LVAL prp);

/* xlsys.c */

LVAL xget_env(void);
LVAL xload(void);
LVAL xtranscript(void);
LVAL xtype(void);
LVAL xbaktrace(void);
LVAL xexit(void);
LVAL xpeek(void);
LVAL xpoke(void);
LVAL xaddrs(void);

/* macstuff, unixstuff, winstuff */

extern const char os_pathchar;
extern const char os_sepchar;

void osinit(char *banner);
void oserror(char *msg);
void osfinish(void);
int osclose(FILE *fp);
void osflush(void);
void oscheck(void);
int osaputc(int ch, FILE *fp);
void osoutflush(FILE *fp);
int osbputc(int ch, FILE *fp);
void ostputc(int ch);
void ostoutflush();
int osagetc(FILE *fp);
int osbgetc(FILE *fp);
int ostgetc(void);
void ossymbols(void);
LVAL xlinfo(void);
LVAL xsetdir(void);
int osdir_list_start(char *path);
char *osdir_list_next();
void osdir_list_finish();
LVAL xosc_enable();
LVAL xget_temp_path();
LVAL xfind_in_xlisp_path();

/* These are now implemented in path.c   -dmazzoni */
const char *return_xlisp_path();
const char *find_in_xlisp_path(const char *fname);
void set_xlisp_path(const char *p);

/* local.c - these procedures are specific to each implementation */

void localinit(void);
void localsymbols(void);
void print_local_gc_info(void);