-
Notifications
You must be signed in to change notification settings - Fork 4
/
locals.h
68 lines (56 loc) · 2.51 KB
/
locals.h
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
#ifndef BNLISP_LOCALS_H
#define BNLISP_LOCALS_H
/* as bnl would say, this is
m # # "
mm#mm # mm mmm #mmm mmm mmmm
# #" # #" # #" "# # #" "#
# # # #"""" # # # # #
"mm # # "#mm" ##m#" mm#mm "#m"#
m #
""
# " m
mmm# mmm m mm mm#mm m m
#" "# # #" " # "m m"
# # # # # #m#
"#m## mm#mm # "mm "#
m"
""
this file defines some macros for keeping track of
pointers to lisp objects in C so that they can be properly
referenced after a garbage collection
*/
/* frame pointer variable name*/
#define FP frame_pointer
#define END_FRAME ((void *) -1)
/* the ugly end of C */
#define LOCALS1(name1) \
void *locals_frame_[3] = {}; \
obj_t **name1 = (obj_t **)(locals_frame_ + 1); \
locals_frame_[0] = FP; \
locals_frame_[2] = END_FRAME; \
FP = locals_frame_;
#define LOCALS2(name1, name2) \
void *locals_frame_[4] = {}; \
obj_t **name1 = (obj_t **)(locals_frame_ + 1); \
obj_t **name2 = (obj_t **)(locals_frame_ + 2); \
locals_frame_[0] = FP; \
locals_frame_[3] = END_FRAME; \
FP = locals_frame_;
#define LOCALS3(name1, name2, name3) \
void *locals_frame_[5] = {}; \
obj_t **name1 = (obj_t **)(locals_frame_ + 1); \
obj_t **name2 = (obj_t **)(locals_frame_ + 2); \
obj_t **name3 = (obj_t **)(locals_frame_ + 3); \
locals_frame_[0] = FP; \
locals_frame_[4] = END_FRAME; \
FP = locals_frame_;
#define LOCALS4(name1, name2, name3, name4) \
void *locals_frame_[6] = {}; \
obj_t **name1 = (obj_t **)(locals_frame_ + 1); \
obj_t **name2 = (obj_t **)(locals_frame_ + 2); \
obj_t **name3 = (obj_t **)(locals_frame_ + 3); \
obj_t **name4 = (obj_t **)(locals_frame_ + 4); \
locals_frame_[0] = FP; \
locals_frame_[5] = END_FRAME; \
FP = locals_frame_;
#endif