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