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