This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Heap decorruption.
[perl5.git] / opcode.pl
1 #!/usr/bin/perl
2
3 unlink "opcode.h", "opnames.h";
4 open(OC, ">opcode.h") || die "Can't create opcode.h: $!\n";
5 open(ON, ">opnames.h") || die "Can't create opnames.h: $!\n";
6 select OC;
7
8 # Read data.
9
10 while (<DATA>) {
11     chop;
12     next unless $_;
13     next if /^#/;
14     ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
15
16     warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc};
17     die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key};
18     $seen{$desc} = qq[description of opcode "$key"];
19     $seen{$key} = qq[opcode "$key"];
20
21     push(@ops, $key);
22     $desc{$key} = $desc;
23     $check{$key} = $check;
24     $ckname{$check}++;
25     $flags{$key} = $flags;
26     $args{$key} = $args;
27 }
28
29 # Emit defines.
30
31 $i = 0;
32 print <<"END";
33 /* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
34    This file is built by opcode.pl from its data.  Any changes made here
35    will be lost!
36 */
37
38 #define Perl_pp_i_preinc Perl_pp_preinc
39 #define Perl_pp_i_predec Perl_pp_predec
40 #define Perl_pp_i_postinc Perl_pp_postinc
41 #define Perl_pp_i_postdec Perl_pp_postdec
42
43 END
44
45 print ON <<"END";
46 /* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
47    This file is built by opcode.pl from its data.  Any changes made here
48    will be lost!
49 */
50
51 typedef enum opcode {
52 END
53
54 for (@ops) {
55     print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
56 }
57 print ON "\t", &tab(3,"OP_max"), "\n";
58 print ON "} opcode;\n";
59 print ON "\n#define MAXO ", scalar @ops, "\n\n"; 
60
61 # Emit op names and descriptions.
62
63 print <<END;
64
65 START_EXTERN_C
66
67 #ifndef DOINIT
68 EXT char *PL_op_name[];
69 #else
70 EXT char *PL_op_name[] = {
71 END
72
73 for (@ops) {
74     print qq(\t"$_",\n);
75 }
76
77 print <<END;
78 };
79 #endif
80
81 END
82
83 print <<END;
84 #ifndef DOINIT
85 EXT char *PL_op_desc[];
86 #else
87 EXT char *PL_op_desc[] = {
88 END
89
90 for (@ops) {
91     my($safe_desc) = $desc{$_};
92
93     # Have to escape double quotes and escape characters.    
94     $safe_desc =~ s/(^|[^\\])([\\"])/$1\\$2/g;
95
96     print qq(\t"$safe_desc",\n);
97 }
98
99 print <<END;
100 };
101 #endif
102
103 END_EXTERN_C
104
105 END
106
107 # Emit function declarations.
108
109 #for (sort keys %ckname) {
110 #    print "OP *\t", &tab(3,$_),"(pTHX_ OP* o);\n";
111 #}
112 #
113 #print "\n";
114 #
115 #for (@ops) {
116 #    print "OP *\t", &tab(3, "pp_$_"), "(pTHX);\n";
117 #}
118
119 # Emit ppcode switch array.
120
121 print <<END;
122
123 START_EXTERN_C
124
125 #ifndef DOINIT
126 EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX);
127 #else
128 EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX) = {
129 END
130
131 for (@ops) {
132     print "\tMEMBER_TO_FPTR(Perl_pp_$_),\n";
133 }
134
135 print <<END;
136 };
137 #endif
138
139 END
140
141 # Emit check routines.
142
143 print <<END;
144 #ifndef DOINIT
145 EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op);
146 #else
147 EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op) = {
148 END
149
150 for (@ops) {
151     print "\t", &tab(3, "MEMBER_TO_FPTR(Perl_$check{$_}),"), "\t/* $_ */\n";
152 }
153
154 print <<END;
155 };
156 #endif
157
158 END
159
160 # Emit allowed argument types.
161
162 print <<END;
163 #ifndef DOINIT
164 EXT U32 PL_opargs[];
165 #else
166 EXT U32 PL_opargs[] = {
167 END
168
169 %argnum = (
170     S,  1,              # scalar
171     L,  2,              # list
172     A,  3,              # array value
173     H,  4,              # hash value
174     C,  5,              # code value
175     F,  6,              # file value
176     R,  7,              # scalar reference
177 );
178
179 %opclass = (
180     '0',  0,            # baseop
181     '1',  1,            # unop
182     '2',  2,            # binop
183     '|',  3,            # logop
184     '@',  4,            # listop
185     '/',  5,            # pmop
186     '$',  6,            # svop_or_padop
187     '#',  7,            # padop
188     '"',  8,            # pvop_or_svop
189     '{',  9,            # loop
190     ';',  10,           # cop
191     '%',  11,           # baseop_or_unop
192     '-',  12,           # filestatop
193     '}',  13,           # loopexop
194 );
195
196 my %OP_IS_SOCKET;
197 my %OP_IS_FILETEST;
198
199 for (@ops) {
200     $argsum = 0;
201     $flags = $flags{$_};
202     $argsum |= 1 if $flags =~ /m/;              # needs stack mark
203     $argsum |= 2 if $flags =~ /f/;              # fold constants
204     $argsum |= 4 if $flags =~ /s/;              # always produces scalar
205     $argsum |= 8 if $flags =~ /t/;              # needs target scalar
206     $argsum |= (8|256) if $flags =~ /T/;        # ... which may be lexical
207     $argsum |= 16 if $flags =~ /i/;             # always produces integer
208     $argsum |= 32 if $flags =~ /I/;             # has corresponding int op
209     $argsum |= 64 if $flags =~ /d/;             # danger, unknown side effects
210     $argsum |= 128 if $flags =~ /u/;            # defaults to $_
211
212     $flags =~ /([\W\d_])/ or die qq[Opcode "$_" has no class indicator];
213     $argsum |= $opclass{$1} << 9;
214     $mul = 0x2000;                              # 2 ^ OASHIFT
215     for $arg (split(' ',$args{$_})) {
216         if ($arg =~ /^F/) {
217            $OP_IS_SOCKET{$_}   = 1 if $arg =~ s/s//;
218            $OP_IS_FILETEST{$_} = 1 if $arg =~ s/-//;
219         }
220         $argnum = ($arg =~ s/\?//) ? 8 : 0;
221         die "op = $_, arg = $arg\n" unless length($arg) == 1;
222         $argnum += $argnum{$arg};
223         warn "# Conflicting bit 32 for '$_'.\n"
224             if $argnum & 8 and $mul == 0x10000000;
225         $argsum += $argnum * $mul;
226         $mul <<= 4;
227     }
228     $argsum = sprintf("0x%08x", $argsum);
229     print "\t", &tab(3, "$argsum,"), "/* $_ */\n";
230 }
231
232 print <<END;
233 };
234 #endif
235
236 END_EXTERN_C
237 END
238
239 if (keys %OP_IS_SOCKET) {
240     print ON "\n#define OP_IS_SOCKET(op)        \\\n\t(";
241     print ON join(" || \\\n\t ",
242                map { "(op) == OP_" . uc() } sort keys %OP_IS_SOCKET);
243     print ON ")\n\n";
244 }
245
246 if (keys %OP_IS_FILETEST) {
247     print ON "\n#define OP_IS_FILETEST(op)      \\\n\t(";
248     print ON join(" || \\\n\t ",
249                map { "(op) == OP_" . uc() } sort keys %OP_IS_FILETEST);
250     print ON ")\n\n";
251 }
252
253 close OC or die "Error closing opcode.h: $!";
254 close ON or die "Error closing opnames.h: $!";
255
256 unlink "pp_proto.h";
257 unlink "pp.sym";
258 open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
259 open PPSYM, '>pp.sym' or die "Error creating pp.sym: $!";
260
261 print PP <<"END";
262 /* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
263    This file is built by opcode.pl from its data.  Any changes made here
264    will be lost!
265 */
266
267 END
268
269 print PPSYM <<"END";
270 #
271 # !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!! 
272 #   This file is built by opcode.pl from its data.  Any changes made here
273 #   will be lost!
274 #
275
276 END
277
278
279 for (sort keys %ckname) {
280     print PP "PERL_CKDEF(Perl_$_)\n";
281     print PPSYM "Perl_$_\n";
282 #OP *\t", &tab(3,$_),"(OP* o);\n";
283 }
284
285 print PP "\n\n";
286
287 for (@ops) {
288     next if /^i_(pre|post)(inc|dec)$/;
289     print PP "PERL_PPDEF(Perl_pp_$_)\n";
290     print PPSYM "Perl_pp_$_\n";
291 }
292
293 close PP or die "Error closing pp_proto.h: $!";
294 close PPSYM or die "Error closing pp.sym: $!";
295
296 ###########################################################################
297 sub tab {
298     local($l, $t) = @_;
299     $t .= "\t" x ($l - (length($t) + 1) / 8);
300     $t;
301 }
302 ###########################################################################
303
304 # Some comments about 'T' opcode classifier:
305
306 # Safe to set if the ppcode uses:
307 #       tryAMAGICbin, tryAMAGICun, SETn, SETi, SETu, PUSHn, PUSHTARG, SETTARG,
308 #       SETs(TARG), XPUSHn, XPUSHu,
309
310 # Unsafe to set if the ppcode uses dTARG or [X]RETPUSH[YES|NO|UNDEF]
311
312 # lt and friends do SETs (including ncmp, but not scmp)
313
314 # Additional mode of failure: the opcode can modify TARG before it "used"
315 # all the arguments (or may call an external function which does the same).
316 # If the target coincides with one of the arguments ==> kaboom.
317
318 # pp.c  pos substr each not OK (RETPUSHUNDEF)
319 #       substr vec also not OK due to LV to target (are they???)
320 #       ref not OK (RETPUSHNO)
321 #       trans not OK (dTARG; TARG = sv_newmortal();)
322 #       ucfirst etc not OK: TMP arg processed inplace
323 #       quotemeta not OK (unsafe when TARG == arg)
324 #       each repeat not OK too due to list context
325 #       pack split - unknown whether they are safe
326 #       sprintf: is calling do_sprintf(TARG,...) which can act on TARG
327 #         before other args are processed.
328
329 #       Suspicious wrt "additional mode of failure" (and only it):
330 #       schop, chop, postinc/dec, bit_and etc, negate, complement.
331
332 #       Also suspicious: 4-arg substr, sprintf, uc/lc (POK_only), reverse, pack.
333
334 #       substr/vec: doing TAINT_off()???
335
336 # pp_hot.c
337 #       readline - unknown whether it is safe
338 #       match subst not OK (dTARG)
339 #       grepwhile not OK (not always setting)
340 #       join not OK (unsafe when TARG == arg)
341
342 #       Suspicious wrt "additional mode of failure": concat (dealt with
343 #       in ck_sassign()), join (same).
344
345 # pp_ctl.c
346 #       mapwhile flip caller not OK (not always setting)
347
348 # pp_sys.c
349 #       backtick glob warn die not OK (not always setting)
350 #       warn not OK (RETPUSHYES)
351 #       open fileno getc sysread syswrite ioctl accept shutdown
352 #        ftsize(etc) readlink telldir fork alarm getlogin not OK (RETPUSHUNDEF)
353 #       umask select not OK (XPUSHs(&PL_sv_undef);)
354 #       fileno getc sysread syswrite tell not OK (meth("FILENO" "GETC"))
355 #       sselect shm* sem* msg* syscall - unknown whether they are safe
356 #       gmtime not OK (list context)
357
358 #       Suspicious wrt "additional mode of failure": warn, die, select.
359
360 __END__
361
362 # New ops always go at the very end
363
364 # Nothing.
365
366 null            null operation          ck_null         0       
367 stub            stub                    ck_null         0
368 scalar          scalar                  ck_fun          s%      S
369
370 # Pushy stuff.
371
372 pushmark        pushmark                ck_null         s0      
373 wantarray       wantarray               ck_null         is0     
374
375 const           constant item           ck_svconst      s$      
376
377 gvsv            scalar variable         ck_null         ds$     
378 gv              glob value              ck_null         ds$     
379 gelem           glob elem               ck_null         d2      S S
380 padsv           private variable        ck_null         ds0
381 padav           private array           ck_null         d0
382 padhv           private hash            ck_null         d0
383 padany          private value           ck_null         d0
384
385 pushre          push regexp             ck_null         d/
386
387 # References and stuff.
388
389 rv2gv           ref-to-glob cast        ck_rvconst      ds1     
390 rv2sv           scalar dereference      ck_rvconst      ds1     
391 av2arylen       array length            ck_null         is1     
392 rv2cv           subroutine dereference  ck_rvconst      d1
393 anoncode        anonymous subroutine    ck_anoncode     $       
394 prototype       subroutine prototype    ck_null         s%      S
395 refgen          reference constructor   ck_spair        m1      L
396 srefgen         single ref constructor  ck_null         fs1     S
397 ref             reference-type operator ck_fun          stu%    S?
398 bless           bless                   ck_fun          s@      S S?
399
400 # Pushy I/O.
401
402 backtick        quoted execution (``, qx)       ck_open         t%      
403 # glob defaults its first arg to $_
404 glob            glob                    ck_glob         t@      S?
405 readline        <HANDLE>                ck_null         t%      
406 rcatline        append I/O operator     ck_null         t%      
407
408 # Bindable operators.
409
410 regcmaybe       regexp internal guard   ck_fun          s1      S
411 regcreset       regexp internal reset   ck_fun          s1      S
412 regcomp         regexp compilation      ck_null         s|      S
413 match           pattern match (m//)     ck_match        d/
414 qr              pattern quote (qr//)    ck_match        s/
415 subst           substitution (s///)     ck_null         dis/    S
416 substcont       substitution iterator   ck_null         dis|    
417 trans           transliteration (tr///) ck_null         is"     S
418
419 # Lvalue operators.
420 # sassign is special-cased for op class
421
422 sassign         scalar assignment       ck_sassign      s0
423 aassign         list assignment         ck_null         t2      L L
424
425 chop            chop                    ck_spair        mts%    L
426 schop           scalar chop             ck_null         stu%    S?
427 chomp           chomp                   ck_spair        mTs%    L
428 schomp          scalar chomp            ck_null         sTu%    S?
429 defined         defined operator        ck_defined      isu%    S?
430 undef           undef operator          ck_lfun         s%      S?
431 study           study                   ck_fun          su%     S?
432 pos             match position          ck_lfun         stu%    S?
433
434 preinc          preincrement (++)               ck_lfun         dIs1    S
435 i_preinc        integer preincrement (++)       ck_lfun         dis1    S
436 predec          predecrement (--)               ck_lfun         dIs1    S
437 i_predec        integer predecrement (--)       ck_lfun         dis1    S
438 postinc         postincrement (++)              ck_lfun         dIst1   S
439 i_postinc       integer postincrement (++)      ck_lfun         disT1   S
440 postdec         postdecrement (--)              ck_lfun         dIst1   S
441 i_postdec       integer postdecrement (--)      ck_lfun         disT1   S
442
443 # Ordinary operators.
444
445 pow             exponentiation (**)     ck_null         fsT2    S S
446
447 multiply        multiplication (*)      ck_null         IfsT2   S S
448 i_multiply      integer multiplication (*)      ck_null         ifsT2   S S
449 divide          division (/)            ck_null         IfsT2   S S
450 i_divide        integer division (/)    ck_null         ifsT2   S S
451 modulo          modulus (%)             ck_null         IifsT2  S S
452 i_modulo        integer modulus (%)     ck_null         ifsT2   S S
453 repeat          repeat (x)              ck_repeat       mt2     L S
454
455 add             addition (+)            ck_null         IfsT2   S S
456 i_add           integer addition (+)    ck_null         ifsT2   S S
457 subtract        subtraction (-)         ck_null         IfsT2   S S
458 i_subtract      integer subtraction (-) ck_null         ifsT2   S S
459 concat          concatenation (.) or string     ck_concat       fsT2    S S
460 stringify       string                  ck_fun          fsT@    S
461
462 left_shift      left bitshift (<<)      ck_bitop        fsT2    S S
463 right_shift     right bitshift (>>)     ck_bitop        fsT2    S S
464
465 lt              numeric lt (<)          ck_null         Iifs2   S S
466 i_lt            integer lt (<)          ck_null         ifs2    S S
467 gt              numeric gt (>)          ck_null         Iifs2   S S
468 i_gt            integer gt (>)          ck_null         ifs2    S S
469 le              numeric le (<=)         ck_null         Iifs2   S S
470 i_le            integer le (<=)         ck_null         ifs2    S S
471 ge              numeric ge (>=)         ck_null         Iifs2   S S
472 i_ge            integer ge (>=)         ck_null         ifs2    S S
473 eq              numeric eq (==)         ck_null         Iifs2   S S
474 i_eq            integer eq (==)         ck_null         ifs2    S S
475 ne              numeric ne (!=)         ck_null         Iifs2   S S
476 i_ne            integer ne (!=)         ck_null         ifs2    S S
477 ncmp            numeric comparison (<=>)        ck_null         Iifst2  S S
478 i_ncmp          integer comparison (<=>)        ck_null         ifst2   S S
479
480 slt             string lt               ck_scmp         ifs2    S S
481 sgt             string gt               ck_scmp         ifs2    S S
482 sle             string le               ck_scmp         ifs2    S S
483 sge             string ge               ck_scmp         ifs2    S S
484 seq             string eq               ck_null         ifs2    S S
485 sne             string ne               ck_null         ifs2    S S
486 scmp            string comparison (cmp) ck_scmp         ifst2   S S
487
488 bit_and         bitwise and (&)         ck_bitop        fst2    S S
489 bit_xor         bitwise xor (^)         ck_bitop        fst2    S S
490 bit_or          bitwise or (|)          ck_bitop        fst2    S S
491
492 negate          negation (-)            ck_null         Ifst1   S
493 i_negate        integer negation (-)    ck_null         ifsT1   S
494 not             not                     ck_null         ifs1    S
495 complement      1's complement (~)      ck_bitop        fst1    S
496
497 # High falutin' math.
498
499 atan2           atan2                   ck_fun          fsT@    S S
500 sin             sin                     ck_fun          fsTu%   S?
501 cos             cos                     ck_fun          fsTu%   S?
502 rand            rand                    ck_fun          sT%     S?
503 srand           srand                   ck_fun          s%      S?
504 exp             exp                     ck_fun          fsTu%   S?
505 log             log                     ck_fun          fsTu%   S?
506 sqrt            sqrt                    ck_fun          fsTu%   S?
507
508 # Lowbrow math.
509
510 int             int                     ck_fun          fsTu%   S?
511 hex             hex                     ck_fun          fsTu%   S?
512 oct             oct                     ck_fun          fsTu%   S?
513 abs             abs                     ck_fun          fsTu%   S?
514
515 # String stuff.
516
517 length          length                  ck_lengthconst  isTu%   S?
518 substr          substr                  ck_fun          st@     S S S? S?
519 vec             vec                     ck_fun          ist@    S S S
520
521 index           index                   ck_index        isT@    S S S?
522 rindex          rindex                  ck_index        isT@    S S S?
523
524 sprintf         sprintf                 ck_fun_locale   mfst@   S L
525 formline        formline                ck_fun          ms@     S L
526 ord             ord                     ck_fun          ifsTu%  S?
527 chr             chr                     ck_fun          fsTu%   S?
528 crypt           crypt                   ck_fun          fsT@    S S
529 ucfirst         ucfirst                 ck_fun_locale   fstu%   S?
530 lcfirst         lcfirst                 ck_fun_locale   fstu%   S?
531 uc              uc                      ck_fun_locale   fstu%   S?
532 lc              lc                      ck_fun_locale   fstu%   S?
533 quotemeta       quotemeta               ck_fun          fstu%   S?
534
535 # Arrays.
536
537 rv2av           array dereference       ck_rvconst      dt1     
538 aelemfast       constant array element  ck_null         s$      A S
539 aelem           array element           ck_null         s2      A S
540 aslice          array slice             ck_null         m@      A L
541
542 # Hashes.
543
544 each            each                    ck_fun          %       H
545 values          values                  ck_fun          t%      H
546 keys            keys                    ck_fun          t%      H
547 delete          delete                  ck_delete       %       S
548 exists          exists                  ck_exists       is%     S
549 rv2hv           hash dereference        ck_rvconst      dt1     
550 helem           hash element            ck_null         s2@     H S
551 hslice          hash slice              ck_null         m@      H L
552
553 # Explosives and implosives.
554
555 unpack          unpack                  ck_fun          @       S S
556 pack            pack                    ck_fun          mst@    S L
557 split           split                   ck_split        t@      S S S
558 join            join or string          ck_join         mst@    S L
559
560 # List operators.
561
562 list            list                    ck_null         m@      L
563 lslice          list slice              ck_null         2       H L L
564 anonlist        anonymous list ([])     ck_fun          ms@     L
565 anonhash        anonymous hash ({})     ck_fun          ms@     L
566
567 splice          splice                  ck_fun          m@      A S? S? L
568 push            push                    ck_fun          imsT@   A L
569 pop             pop                     ck_shift        s%      A
570 shift           shift                   ck_shift        s%      A
571 unshift         unshift                 ck_fun          imsT@   A L
572 sort            sort                    ck_sort         m@      C? L
573 reverse         reverse                 ck_fun          mt@     L
574
575 grepstart       grep                    ck_grep         dm@     C L
576 grepwhile       grep iterator           ck_null         dt|     
577
578 mapstart        map                     ck_grep         dm@     C L
579 mapwhile        map iterator            ck_null         dt|
580
581 # Range stuff.
582
583 range           flipflop                ck_null         |       S S
584 flip            range (or flip)         ck_null         1       S S
585 flop            range (or flop)         ck_null         1
586
587 # Control.
588
589 and             logical and (&&)                ck_null         |       
590 or              logical or (||)                 ck_null         |       
591 xor             logical xor                     ck_null         fs2     S S     
592 cond_expr       conditional expression          ck_null         d|      
593 andassign       logical and assignment (&&=)    ck_null         s|      
594 orassign        logical or assignment (||=)     ck_null         s|      
595
596 method          method lookup           ck_method       d1
597 entersub        subroutine entry        ck_subr         dmt1    L
598 leavesub        subroutine exit         ck_null         1       
599 leavesublv      lvalue subroutine exit  ck_null         1       
600 caller          caller                  ck_fun          t%      S?
601 warn            warn                    ck_fun          imst@   L
602 die             die                     ck_fun          dimst@  L
603 reset           symbol reset            ck_fun          is%     S?
604
605 lineseq         line sequence           ck_null         @       
606 nextstate       next statement          ck_null         s;      
607 dbstate         debug next statement    ck_null         s;      
608 unstack         iteration finalizer     ck_null         s0
609 enter           block entry             ck_null         0       
610 leave           block exit              ck_null         @       
611 scope           block                   ck_null         @       
612 enteriter       foreach loop entry      ck_null         d{      
613 iter            foreach loop iterator   ck_null         0       
614 enterloop       loop entry              ck_null         d{      
615 leaveloop       loop exit               ck_null         2       
616 return          return                  ck_null         dm@     L
617 last            last                    ck_null         ds}     
618 next            next                    ck_null         ds}     
619 redo            redo                    ck_null         ds}     
620 dump            dump                    ck_null         ds}     
621 goto            goto                    ck_null         ds}     
622 exit            exit                    ck_exit         ds%     S?
623 # continued below
624
625 #nswitch        numeric switch          ck_null         d       
626 #cswitch        character switch        ck_null         d       
627
628 # I/O.
629
630 open            open                    ck_open         ist@    F S? L
631 close           close                   ck_fun          is%     F?
632 pipe_op         pipe                    ck_fun          is@     F F
633
634 fileno          fileno                  ck_fun          ist%    F
635 umask           umask                   ck_fun          ist%    S?
636 binmode         binmode                 ck_fun          s@      F S?
637
638 tie             tie                     ck_fun          idms@   R S L
639 untie           untie                   ck_fun          is%     R
640 tied            tied                    ck_fun          s%      R
641 dbmopen         dbmopen                 ck_fun          is@     H S S
642 dbmclose        dbmclose                ck_fun          is%     H
643
644 sselect         select system call      ck_select       t@      S S S S
645 select          select                  ck_select       st@     F?
646
647 getc            getc                    ck_eof          st%     F?
648 read            read                    ck_fun          imst@   F R S S?
649 enterwrite      write                   ck_fun          dis%    F?
650 leavewrite      write exit              ck_null         1       
651
652 prtf            printf                  ck_listiob      ims@    F? L
653 print           print                   ck_listiob      ims@    F? L
654
655 sysopen         sysopen                 ck_fun          s@      F S S S?
656 sysseek         sysseek                 ck_fun          s@      F S S
657 sysread         sysread                 ck_fun          imst@   F R S S?
658 syswrite        syswrite                ck_fun          imst@   F S S? S?
659
660 send            send                    ck_fun          imst@   Fs S S S?
661 recv            recv                    ck_fun          imst@   Fs R S S
662
663 eof             eof                     ck_eof          is%     F?
664 tell            tell                    ck_fun          st%     F?
665 seek            seek                    ck_fun          s@      F S S
666 # truncate really behaves as if it had both "S S" and "F S"
667 truncate        truncate                ck_trunc        is@     S S
668
669 fcntl           fcntl                   ck_fun          st@     F S S
670 ioctl           ioctl                   ck_fun          st@     F S S
671 flock           flock                   ck_fun          isT@    F S
672
673 # Sockets.
674
675 socket          socket                  ck_fun          is@     Fs S S S
676 sockpair        socketpair              ck_fun          is@     Fs Fs S S S
677
678 bind            bind                    ck_fun          is@     Fs S
679 connect         connect                 ck_fun          is@     Fs S
680 listen          listen                  ck_fun          is@     Fs S
681 accept          accept                  ck_fun          ist@    Fs Fs
682 shutdown        shutdown                ck_fun          ist@    Fs S
683
684 gsockopt        getsockopt              ck_fun          is@     Fs S S
685 ssockopt        setsockopt              ck_fun          is@     Fs S S S
686
687 getsockname     getsockname             ck_fun          is%     Fs
688 getpeername     getpeername             ck_fun          is%     Fs
689
690 # Stat calls.
691
692 lstat           lstat                   ck_ftst         u-      F
693 stat            stat                    ck_ftst         u-      F
694 ftrread         -R                      ck_ftst         isu-    F-
695 ftrwrite        -W                      ck_ftst         isu-    F-
696 ftrexec         -X                      ck_ftst         isu-    F-
697 fteread         -r                      ck_ftst         isu-    F-
698 ftewrite        -w                      ck_ftst         isu-    F-
699 fteexec         -x                      ck_ftst         isu-    F-
700 ftis            -e                      ck_ftst         isu-    F-
701 fteowned        -O                      ck_ftst         isu-    F-
702 ftrowned        -o                      ck_ftst         isu-    F-
703 ftzero          -z                      ck_ftst         isu-    F-
704 ftsize          -s                      ck_ftst         istu-   F-
705 ftmtime         -M                      ck_ftst         stu-    F-
706 ftatime         -A                      ck_ftst         stu-    F-
707 ftctime         -C                      ck_ftst         stu-    F-
708 ftsock          -S                      ck_ftst         isu-    F-
709 ftchr           -c                      ck_ftst         isu-    F-
710 ftblk           -b                      ck_ftst         isu-    F-
711 ftfile          -f                      ck_ftst         isu-    F-
712 ftdir           -d                      ck_ftst         isu-    F-
713 ftpipe          -p                      ck_ftst         isu-    F-
714 ftlink          -l                      ck_ftst         isu-    F-
715 ftsuid          -u                      ck_ftst         isu-    F-
716 ftsgid          -g                      ck_ftst         isu-    F-
717 ftsvtx          -k                      ck_ftst         isu-    F-
718 fttty           -t                      ck_ftst         is-     F-
719 fttext          -T                      ck_ftst         isu-    F-
720 ftbinary        -B                      ck_ftst         isu-    F-
721
722 # File calls.
723
724 chdir           chdir                   ck_fun          isT%    S?
725 chown           chown                   ck_fun          imsT@   L
726 chroot          chroot                  ck_fun          isTu%   S?
727 unlink          unlink                  ck_fun          imsTu@  L
728 chmod           chmod                   ck_fun          imsT@   L
729 utime           utime                   ck_fun          imsT@   L
730 rename          rename                  ck_fun          isT@    S S
731 link            link                    ck_fun          isT@    S S
732 symlink         symlink                 ck_fun          isT@    S S
733 readlink        readlink                ck_fun          stu%    S?
734 mkdir           mkdir                   ck_fun          isT@    S S?
735 rmdir           rmdir                   ck_fun          isTu%   S?
736
737 # Directory calls.
738
739 open_dir        opendir                 ck_fun          is@     F S
740 readdir         readdir                 ck_fun          %       F
741 telldir         telldir                 ck_fun          st%     F
742 seekdir         seekdir                 ck_fun          s@      F S
743 rewinddir       rewinddir               ck_fun          s%      F
744 closedir        closedir                ck_fun          is%     F
745
746 # Process control.
747
748 fork            fork                    ck_null         ist0    
749 wait            wait                    ck_null         isT0    
750 waitpid         waitpid                 ck_fun          isT@    S S
751 system          system                  ck_exec         imsT@   S? L
752 exec            exec                    ck_exec         dimsT@  S? L
753 kill            kill                    ck_fun          dimsT@  L
754 getppid         getppid                 ck_null         isT0    
755 getpgrp         getpgrp                 ck_fun          isT%    S?
756 setpgrp         setpgrp                 ck_fun          isT@    S? S?
757 getpriority     getpriority             ck_fun          isT@    S S
758 setpriority     setpriority             ck_fun          isT@    S S S
759
760 # Time calls.
761
762 # NOTE: MacOS patches the 'i' of time() away later when the interpreter
763 # is created because in MacOS time() is already returning times > 2**31-1,
764 # that is, non-integers.
765
766 time            time                    ck_null         isT0    
767 tms             times                   ck_null         0       
768 localtime       localtime               ck_fun          t%      S?
769 gmtime          gmtime                  ck_fun          t%      S?
770 alarm           alarm                   ck_fun          istu%   S?
771 sleep           sleep                   ck_fun          isT%    S?
772
773 # Shared memory.
774
775 shmget          shmget                  ck_fun          imst@   S S S
776 shmctl          shmctl                  ck_fun          imst@   S S S
777 shmread         shmread                 ck_fun          imst@   S S S S
778 shmwrite        shmwrite                ck_fun          imst@   S S S S
779
780 # Message passing.
781
782 msgget          msgget                  ck_fun          imst@   S S
783 msgctl          msgctl                  ck_fun          imst@   S S S
784 msgsnd          msgsnd                  ck_fun          imst@   S S S
785 msgrcv          msgrcv                  ck_fun          imst@   S S S S S
786
787 # Semaphores.
788
789 semget          semget                  ck_fun          imst@   S S S
790 semctl          semctl                  ck_fun          imst@   S S S S
791 semop           semop                   ck_fun          imst@   S S
792
793 # Eval.
794
795 require         require                 ck_require      du%     S?
796 dofile          do "file"               ck_fun          d1      S
797 entereval       eval "string"           ck_eval         d%      S
798 leaveeval       eval "string" exit      ck_null         1       S
799 #evalonce       eval constant string    ck_null         d1      S
800 entertry        eval {block}            ck_null         |       
801 leavetry        eval {block} exit       ck_null         @       
802
803 # Get system info.
804
805 ghbyname        gethostbyname           ck_fun          %       S
806 ghbyaddr        gethostbyaddr           ck_fun          @       S S
807 ghostent        gethostent              ck_null         0       
808 gnbyname        getnetbyname            ck_fun          %       S
809 gnbyaddr        getnetbyaddr            ck_fun          @       S S
810 gnetent         getnetent               ck_null         0       
811 gpbyname        getprotobyname          ck_fun          %       S
812 gpbynumber      getprotobynumber        ck_fun          @       S
813 gprotoent       getprotoent             ck_null         0       
814 gsbyname        getservbyname           ck_fun          @       S S
815 gsbyport        getservbyport           ck_fun          @       S S
816 gservent        getservent              ck_null         0       
817 shostent        sethostent              ck_fun          is%     S
818 snetent         setnetent               ck_fun          is%     S
819 sprotoent       setprotoent             ck_fun          is%     S
820 sservent        setservent              ck_fun          is%     S
821 ehostent        endhostent              ck_null         is0     
822 enetent         endnetent               ck_null         is0     
823 eprotoent       endprotoent             ck_null         is0     
824 eservent        endservent              ck_null         is0     
825 gpwnam          getpwnam                ck_fun          %       S
826 gpwuid          getpwuid                ck_fun          %       S
827 gpwent          getpwent                ck_null         0       
828 spwent          setpwent                ck_null         is0     
829 epwent          endpwent                ck_null         is0     
830 ggrnam          getgrnam                ck_fun          %       S
831 ggrgid          getgrgid                ck_fun          %       S
832 ggrent          getgrent                ck_null         0       
833 sgrent          setgrent                ck_null         is0     
834 egrent          endgrent                ck_null         is0     
835 getlogin        getlogin                ck_null         st0     
836
837 # Miscellaneous.
838
839 syscall         syscall                 ck_fun          imst@   S L
840
841 # For multi-threading
842 lock            lock                    ck_rfun         s%      S
843 threadsv        per-thread value        ck_null         ds0
844
845 # Control (contd.)
846 setstate        set statement info      ck_null         s;
847 method_named    method with known name  ck_null         d$