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