File: structures

package info (click to toggle)
picolisp 3.1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,100 kB
  • sloc: ansic: 14,205; lisp: 795; makefile: 290; sh: 13
file content (323 lines) | stat: -rw-r--r-- 9,038 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
# 07jun12abu
# (c) Software Lab. Alexander Burger


   ### Primary data types ###

   cnt   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxS010
   big   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxS100
   sym   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1000
   pair  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0000


         Bignum
         |
         V
      +-----+-----+
      | DIG |  |  |
      +-----+--+--+
               |
               V
            +-----+-----+
            | DIG |  |  |
            +-----+--+--+
                     |
                     V
                  +-----+-----+
                  | DIG | CNT |
                  +-----+-----+


      Pair
      |
      V
      +-----+-----+
      | CAR | CDR |
      +-----+-----+


            Symbol
            |
            V
      +-----+-----+                                +-----+-----+
      |  |  | VAL |                                |'cba'|'fed'|
      +--+--+-----+                                +-----+-----+
         | tail                                       ^
         |                                            |
         V                                            | name
         +-----+-----+     +-----+-----+     +-----+--+--+
         |  |  |  ---+---> | KEY |  ---+---> |  |  |  |  |
         +--+--+-----+     +-----+-----+     +--+--+-----+
            |                                   |
            V                                   V
            +-----+-----+                       +-----+-----+
            | VAL | KEY |                       | VAL | KEY |
            +-----+-----+                       +-----+-----+


      NIL:  /
            |
            V
      +-----+-----+-----+-----+
      |'LIN'|  /  |  /  |  /  |
      +-----+--+--+-----+-----+


   Symbol tail
      Internal/Transient
         0010 Short name
         0100 Long name
         0000 Properties

      External
         1010 Short name
         1000 Properties

   Name final short
      Internals, Transients
         0000.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx0010
           60      52      44      36      28      20      12       4

      Externals
         42 bit Object (4 Tera objects)
         16 bit File (64 K files)
          2 bit Status
            Loaded    01........
            Dirty     10........
            Deleted   11........

         1+2 Bytes: 1 file, 64K objects                  {177777}
         1+3 Bytes: 16 files, 1M objects               {O3777777}
         1+4 Bytes: 256 files, 16M objects           {OO77777777}
         1+5 Bytes: 256 files, 4G objects         {OO37777777777}
         1+6 Bytes: 65536 files, 4G objects     {OOOO37777777777}
         1+8 Bytes: 65536 files, 4T objects  {OOOO77777777777777}
         (2 + 10 + 8 + 12 + 8 + 20)
         xx.xxxxxxxxx.xxxxxxx.xxxxxxxxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxE010
           obj       file    obj         file    obj
                     ^6      ^5      ^4      ^3      ^2


   ### Heap ###

      Heaps       Avail
      |           |
      |           |  +-----------------------+
      |           |  |                       |
      V           V  |                       V
      +-----+-----+--+--+-----+-----+-----+-----+-----+---     ---+-----+
      |           |  |  |     |           |  /  |     |    ...    |  |  |
      +-----+-----+-----+-----+-----+-----+-----+-----+---     ---+--+--+
                                                                     |
                                                                     |
                                                                     +----->


   ### Stack ###

      Saved values:
                        ^
                        |
         +---> LINK ----+
         |     val1
         |     val2
         |     ...
         |     valN
         +---- LINK  <-- L


      Bind frame:
                        ^
               Bind     |
         +---> LINK ----+
         |     val1
         |     sym1
         |     ...
         |     valN
         |     symN
         +---- LINK  <-- L <-- Bind
               eswp


      VarArgs frame:
                        ^
               Bind     |
         +---> LINK ----+
         |     val1
         |     sym1
         |     ...
         |     valN
         |     symN
         +---- LINK <---+  <-- Bind
               eswp     |
               Next     |
               Args     |
         +---> LINK ----+  <-- Next
         |     arg1
         |     ...
         |     argN        <-- Args
         +---- LINK  <-- L


      Apply args:
                        ^
                        |
         +---> LINK ----+
         |     ...
         |     fun         <-- Y
         |     arg1
         |     ...
         |     argN        <-- Z
         |     ...
         +---- LINK <-- L


      Apply frame:
                        ^
               Apply    |
         +---> LINK ----+
         |     ...
         |     valN <-+       (gc)
         |     zero   |
         |     NIL    |       (gc)
         |     carN --+ <-+
         |     ...        |
         |     val1 <-+   |   (gc)
         |     zero   |   |
         |     cdr1 --|---+   (gc)
         | +-> car1 --+
         | +-- cdr            (gc)
         |     fun         <-- exe
         +---- LINK  <-- L <-- Apply


      Catch frame:
                        ^
               X        |
               Y        |
               Z        |
               L        |
         <III> [env]    |
         <II>  fin      |
         <I>   tag      |
               LINK ----+  <-- Catch


      I/O frame:
                        ^
         <III> put/get  |
         <II>  pid      |
         <I>   fd       |
               LINK ----+  <-- inFrames, outFrames, errFrames, ctlFrames


      Coroutine frame:
                        ^
               X        |
               Y        |
               Z        |
               L        |
         <III> [env]    |
         <II>  seg      |
         <I>   lim      |
               LINK ----+  <-- co7


      Stack segment:
         <-I>  tag      # Tag
         <-II> stk      # Stack pointer --+
               [env]    # Environment     |
               Stack ...                  |
               X                          |
               Y                          |
               Z                          |
               L  <-----------------------+


   ### Memory ###

      inFile:
         -->   fd       # File descriptor
         <I>   ix       # Read index
         <II>  cnt      # Buffer count
         <III> next     # Next character
         <IV>  line     # Line number
         <V>   src      # Source line number
         <VI>  name     # Filename
         <VII> buf      # Buffer [BUFSIZ]

      outFile:
         -->   fd       # File descriptor
         <I>   ix       # Read index
         <II>  tty      # TTY flag
         <III> buf      # Buffer [BUFSIZ]


      child:
         -->   pid      # Process ID
         <I>   hear     # Pipe read end
         <II>  tell     # Pipe write end
         <III> ofs      # Buffer offset
         <IV>  cnt      # Buffer count
         <V>   buf      # Buffer pointer

                  +--------------------------+ Mic
                  |
                  |  +-----------------+ Tell         <Child>
                  |  |
                  |  +-----------------> Hear
      <Parent>    |  |
                  |  |
         Spkr <---+  |
                  |  |
                  |  |
                  |  +-----------------+ Tell
                  |  |
                  |  +-----------------> Hear         <Child>
                  |
                  +--------------------------+ Mic


   ### Database file ###

                  +-------------+-+-------------+-+----+
      Block 0:    |   Free       0|   Next       0| << |
                  +-------------+-+-------------+-+----+
                  0               BLK                  2*Blk+1


                  +-------------+-+
      Free:       |   Link       0|
                  +-------------+-+
                  0


                  +-------------+-+----
      ID-Block:   |   Link       1| Data
                  +-------------+-+----
                  0              BLK


                  +-------------+-+----
      EXT-Block:  |   Link       n| Data
                  +-------------+-+----
                  0              BLK


      dbFile:  # Size VIII (64 bytes)
         -->   fd       # File descriptor
         <I>   db       # File number
         <II>  sh       # Block shift
         <III> siz      # Block size (64 << sh)
         <IV>  flgs     # Flags: Lock(0), Dirty(1)
         <V>   marks    # Mark vector size
         <VI>  mark     # Mark bit vector
         <VII> fluse    # Free list use count


   ### Assumptions ###

   - 8 bit per byte
   - 64 bit per word
   - Stack grows downwards, aligned to 64 bit
   - Memory access legal also at 4-byte boundaries